+ 1

list slicing prob

how come I cant slice this list whats the correct way to do it? move=['car, bike, helicopter, plane'] print(move) print("Now slicing") move[2:] print(move) It prints either the whole list or just empty []

26th Apr 2018, 5:42 AM
sovietcat
sovietcat - avatar
3 Réponses
+ 6
Its because your array consists of only one string ‘car, bike, helicopter, plane’. You should instead do: move = [‘car’, ‘bike’, ‘helicopter’, ‘plane’] Then it should work
26th Apr 2018, 5:44 AM
Ali Zhussupov
Ali Zhussupov - avatar
+ 1
Ali Zhussupov oh right thx I forgot bout this
26th Apr 2018, 6:39 AM
sovietcat
sovietcat - avatar
0
happy to help)
26th Apr 2018, 8:25 AM
Ali Zhussupov
Ali Zhussupov - avatar