+1

why isnt the reversed method working here??

https://code.sololearn.com/c1GyU5ku09Ro/?ref=app

7/11/2019 10:38:14 AM

PRO

4 Answers

New Answer

+7

reversed() method returns an iterator (not a list) that accesses the given sequence in the reverse order To make a list from the iterator use list() function Use new_list2 = list(reversed(tech_wishlist)) Instead of new_list2 = reversed(tech_wishlist)

+6

https://www.geeksforgeeks.org/iterators-in-python/

+1

Om Kumar what is an iterator?

0

some options here new_list2 = tech_wishlist[::-1] print(new_list2) for i in reversed(tech_wishlist): print(i) tech_wishlist.reverse() print(tech_wishlist)