What's that ?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What's that ??

lst = [10, 11, 12, 13, 14, 15] lst.reverse() print("Using reverse() ", lst)   print("Using reversed() ", list(reversed(lst)))

5th Feb 2023, 6:01 PM
Gaurav Kumar
Gaurav Kumar - avatar
2 Answers
+ 13
Gaurav K , > for the second try with reversed(), we should use the same basic data as for reverse(). > currently the second try uses an already reversed list from the first try lst = [10, 11, 12, 13, 14, 15] lst.reverse() print("Using reverse() ", lst) lst = [10, 11, 12, 13, 14, 15] print("Using reversed() ", list(reversed(lst))) > both results are giving the same output of: [15, 14, 13, 12, 11, 10]
5th Feb 2023, 6:13 PM
Lothar
Lothar - avatar
+ 2
Thanku
5th Feb 2023, 7:46 PM
Gaurav Kumar
Gaurav Kumar - avatar