I'm confused by the following code:
lst = ['1','2','3']
s = [str(i) for i in lst]
print(s)
and
lst = ['1','2','3']
for i in lst:
s = [str(i)]
print(s)
Why does the first one print out ['1','2','3']
but the second one only print out ['3']
?
Also, how can I print out ['1','2','3']
with the "normal form" of a for
-loop like the second one (because I don't understand how the first one works).