Categories
Mastering Development

simple list comprehension question python

list=(1,2,3,4)
for x in range(len(list)):
    print(list[x])

1
2
3
4
but print(list) repeats the whole list 4 times ie

1,2,3,4
1,2,3,4
1,2,3,4

how does the x in the print(list[x]) cause only single numbers to come out? Like how could you put what the [x] is doing in english?

Leave a Reply

Your email address will not be published. Required fields are marked *