rintina
February 5, 2022, 7:48am
#1
i have a question regarding Len’s Slice exercise at Python beginner course .
how do i create a 2D list from 2 different lists, i tried :
but is seems the outcome for this function is a list of tuples, as where i want to create a list of list, ie 2D list
i would appreciate an explanation, thank you
mtf
February 5, 2022, 11:14am
#2
Does the exercise ask us to use the zip()
function, or has that not even been taught yet? If not, then the task could be performed manually…
pizza_and_prices = [
['pepperoni', 2],
['pineapple', 6],
...
]
2 Likes
rintina
February 5, 2022, 11:55am
#3
yup, per usual i got a head of myself
so i learned map and zip . now i understand that ZIP returns an object, not a list so i can use map and list function to defin each zip object as a list creating 2D list .
thank you
2 Likes
Yep, they want one to do this manually.
Prior to the revision of this lesson, it did include zip()
. Now zip()
is afterward.
Also, if you do a search for this topic here in the forums, there are many threads that discuss this very same issue.
1 Like