0

Why do this program outputs 1?

l = ['a' 'b' 'c' 'd'] print (len(l)) IT SHOULD OUTPUT 4. HELP?

13th Aug 2020, 10:35 AM
mk2144
mk2144 - avatar
5 Answers
+ 6
Because you didn't put commas after each array element . Like this: l=['a','b','c','d'] print(len(l))
13th Aug 2020, 10:42 AM
Monat15
Monat15 - avatar
+ 3
For some reason, as Monat15 said - you didn't separate the elements with a comma; the list <l> end up having just one element, a string 'abcd'.
13th Aug 2020, 10:46 AM
Ipang
+ 1
I tried again with commas and works. Thank you!
13th Aug 2020, 10:45 AM
mk2144
mk2144 - avatar
0
If I help you, please, rate my answer as the best
13th Aug 2020, 10:48 AM
Monat15
Monat15 - avatar
0
done
13th Aug 2020, 10:52 AM
mk2144
mk2144 - avatar