[Tutor] Help!
Manprit Singh
manpritsinghece at gmail.com
Fri Sep 11 04:22:42 EDT 2020
Dear All,
This can be an answer :
n= 5
a = []
for x in range(n):
a.append(list(range(x, n + x)))
print(a)
will give an output :
[[0, 1, 2, 3, 4],
[1, 2, 3, 4, 5],
[2, 3, 4, 5, 6],
[3, 4, 5, 6, 7],
[4, 5, 6, 7, 8]]
Regards
Manprit Singh
On Fri, Sep 11, 2020 at 1:30 PM Dennis, Lauren <ldennis1 at lion.lmu.edu>
wrote:
> Hello!
> I was wondering if I could get some guidance on how to create a two
> dimensional list using a for loop and range() function. Thank you!
>
> Lauren Dennis
> She, Her, Hers
> Loyola Marymount University | Class of 2021
> Business Management | ldennis1 at lion.lmu.edu
>
>
> _______________________________________________
> 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