0

empty list

How many items are on this list? [2,] 3 1 2

26th Apr 2018, 4:02 PM
Lakshman Patel
Lakshman Patel - avatar
4 Respostas
+ 1
right now python wants to use the comma to separate list items, soit is not an item itself. you can make it one by changing your list to this: [2, ','] In that example the 2 is an integer and the comma is a string character. You can dothe same in the following example except the 2 will now be treated as a string just like the comma. ['2', ','] either way you choose you must separate all items with a comma.
26th Apr 2018, 4:22 PM
synorax
synorax - avatar
0
1 Just use the len() function
26th Apr 2018, 4:03 PM
TurtleShell
TurtleShell - avatar
0
and comma??
26th Apr 2018, 4:11 PM
Lakshman Patel
Lakshman Patel - avatar
0
print(len([2,])) outputs 1
26th Apr 2018, 4:13 PM
TurtleShell
TurtleShell - avatar