a is a list…
If reversed(a) doesn’t return anything then what’s the use of it? When I tried doing:
b = reversed(a); print(b)… It showed this: <list_reverseiterator at 0x1fb3bdee850>
The memory address where the reversed list has been stored… So what is the use of it if I can’t access the reversed list…
About reversed(a):-
Hey @bihan, the reversed() function returns the reversed iterator of the given sequence. This means that the reversed()
function returns an iterator that accesses the given sequence in the reverse order. So to store the reversed list in some variable for printing, you should use it in the following manner :
a=[1,2,3,4,5]
b=list(reversed(a))
print(b)
I hope this helps you clear your doubt !
Happy Coding !
1 Like
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.