[Tutor] Nested list comprehensions
Manprit Singh
manpritsinghece at gmail.com
Sun Oct 18 03:47:37 EDT 2020
Dear sir,
I have already tested the code.....the answer is correct too.
My concern was just to check if my understanding about using nested list
comprehensions is correct or not.
Regards
Manprit Singh
On Sun, 18 Oct, 2020, 13:12 Mark Lawrence, <breamoreboy at gmail.com> wrote:
> On 18/10/2020 06:39, Manprit Singh wrote:
> > Dear sir ,
> >
> > While reading about nested list comprehensions, i have tried to write an
> > example of making a 2D list with m rows and n columns with each element
> of
> > list equals e.
> > Just need to know , if my understanding is correct or not ?
> >
> > def two_d(row, col, ele):
> > return [[ele for _ in range(col)] for _ in range(row)]
> >
> > m = int(input("Enter no of rows"))
> > n = int(input("Enter no of columns"))
> > e = int(input("Enter the element to be placed inside list'))
> > two_d(m, n, e)
> >
> > Regards
> > Manprit Singh
> >
>
> I don't intend doing your testing for you, so please try the code in the
> interactive interpreter or place the code in a script and run it.
>
> --
> My fellow Pythonistas, ask not what our language can do for you, ask
> what you can do for our language.
>
> Mark Lawrence
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list