0

The reverse function is giving an output as none. What is the correct usage?

letters = ['p', 'q', 'r', 's', 'p', 'u'] print(letters.index('r')) print(letters.index('p')) print(letters.reverse())

26th Jun 2017, 4:10 AM
Abhishek Hugar
Abhishek Hugar - avatar
2 Antworten
+ 3
.reverse does just that - in place. It *changes* the list it is called upon.
26th Jun 2017, 5:55 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar