+ 4

(Py) Is there a way to display the items in a linked lists in reverse order?

Please check my code, I tried to display the items in linked list in a reverse order, and got a warning "error: None-type objects are not iterable". https://code.sololearn.com/cjHDp10AJTH7/?ref=app

16th Jan 2022, 3:19 AM
Lea
Lea - avatar
2 Antworten
+ 4
list.reverse() has no return, and it directly reverses the list, thus default return None. You can change it to: run_list.reverse() for ii in run_list: or for ii in (run_list.reverse() or run_list):
16th Jan 2022, 3:36 AM
FanYu
FanYu - avatar
+ 4
𝓕𝓛𝓨 It works! Thank you very much for helping me!
16th Jan 2022, 9:50 AM
Lea
Lea - avatar