+ 1
why isnt the reversed method working here??
4 odpowiedzi
+ 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)
+ 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)