0
list = [0,1,2] for i, v in enumerate(list): print(v+i,end =") #output:024 why?
enumerate
2 Answers
+ 6
you have 3 indexes so you also have 3 values.
indexes: 0 1 2
values : 0 1 2
enumerate goes through an iterable and assigns each value with it's index value in a tuple. PRINT IT OUT IN THE PLAYGROUND.
when you use: print(end='')
the end paramater assigns a new ending character. (instead of '\n' which is default.)
Then you just add the indexes and values and squish em together.
024
+ 1
0+0, 1+1, 2+2