+ 3

'None' output from print(list.reverse())

A = ["Python", "fun"] index = 0 while index <= 2: A.insert(index, "is") index += 1 print(A) print(A.reverse()) A.remove("is") Please tell me what is wrong. All I get from a reversed list is None.

21st Aug 2016, 7:17 AM
Eunjae Lee
Eunjae Lee - avatar
2 Answers
+ 4
with this code you only print the call to the methode and it does not return a value: print(A.reverse()) You have to call the methode before printing the final value of A: A.reverse() print(A) Output: fun, python
22nd Aug 2016, 1:14 AM
Marco Romanin
Marco Romanin - avatar
- 1
reverse() is a methode, which means it does not return a value as opposed to a function which does. if you want to see it's result, you need to use it on a list and print the list. if you like this answer please hit thumb up button
21st Aug 2016, 7:48 AM
jocker-il
jocker-il - avatar