0
why print(list.reverse()) does not work?
7 Answers
+ 14
Try this.
list1 = [1,2,3,4,5]
print (list1)
list1.reverse()
print (list1)
+ 14
I don't Python much, but deriving from programming logic:
It's because list1.reverse() does not return a list to the print() function. What list1.reverse() does is to convert list1 to it's reversed counterpart. You need to manually print list1 after converting it.
+ 13
Please post your entire code for inspection so members can help you tell which part is throwing an error.
+ 1
it does not work because peint(list.reverse()) don't return a list, but convert just reverse list. you must explicitly affect answer with print function.
0
list1 = [1,2,3,4,5]
print (list1)
print(list1.reverse())
Output:
[1, 2, 3, 4, 5]
None
0
Your code worked but why my example gives 'none' as output
0
okay, thanks