Problem : Generator

Chris Angelico rosuav at gmail.com
Fri Feb 15 03:25:58 EST 2019


On Fri, Feb 15, 2019 at 6:57 PM Prahallad Achar <acharbly at gmail.com> wrote:
>
> How about this
> List1=[ 1,2,3,4]
> Rever_gen = ( x*x for x in list1, reversed = True)
>
> Rever_gen gets generator object and iterating it now gets reverse order..
>
> Am I correct here? Suggest me
>

How about reversed(list1) ?

ChrisA


More information about the Python-list mailing list