0

Why does >>>> print(listName.reverse()) not give any output ??

9th Jun 2018, 7:05 PM
Sandeep Singh
Sandeep Singh - avatar
3 Answers
+ 3
Hi Sandeep Singh, You are not having an output because the list method 'reverse', reverses the list in place and returns nothing. If you want to see the output do this: # assuming letters is a list letters.reverse() print(letters)
9th Jun 2018, 7:11 PM
Ulisses Cruz
Ulisses Cruz - avatar
0
here is an approach to get reversed list: print(sorted(['z','y','x'], key=lambda i: i, reverse=False)) Sandeep Singh
9th Jun 2018, 10:37 PM
Flash
- 1
It fails because there is nothing to print. If you put "" around letters, it should have an output
9th Jun 2018, 7:13 PM
Here to help problems!