What does the [0] do in the code len(x[0])? - full code attached

Day 1 on python, came across this code. I just learnt what len() does but I’m confused on the x[0] in line 14? What does that code do? Would appreciate any help!

image

when we have a list, we can access the elements by index/position. Which is what the [0] does, access the first element of the array (arrays are zero-indexed based)

for the future, you could have added this on line 4 or 12:

print(x[0])

to see what result this gives, and then deduce what might have happened

3 Likes