Creating 2D list from 2 different lists

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 :slight_smile:

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],

yup, per usual i got a head of myself :slight_smile:
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 :slight_smile:


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