+ 1

Why does the attached code gives none when when print(letters.reverse()) is interpreted.

https://code.sololearn.com/cQ6FqXQyAhGf/?ref=app

1st Jun 2020, 9:30 PM
Aditi Singh
Aditi Singh - avatar
2 Answers
+ 2
letters.reverse() has no return value so there is nothing to print. The reversing is done in place so the original list is reversed and no new list is created.
1st Jun 2020, 9:37 PM
JME
+ 3
Try this: List = [1, 2, 3, 4] List.reverse() print(List)
1st Jun 2020, 9:45 PM
Namit Jain
Namit Jain - avatar