Creating and Modifying a List in Python: Zip()

Hi everyone,

This question is for STEP 1 Only of this exercise:
Creating and Modifying a List in Python: Zip()

The Instructions for step 1 state: Use zip to create a new variable called names_and_dogs_names that combines names and dogs_names into a zip object.

Make sure to run the code for this step before proceeding to the next instruction!

My code:

names = ['Jenny', 'Alexus', 'Sam', 'Grace']
dogs_names = ['Elphonse', 'Dr. Doggy DDS', 'Carter', 'Ralph']

names_and_dogs_names = zip(names, dogs_names)
print(list(names_and_dogs_names))

The error message: Is names_and_dogs_names a zip() with names first and dogs_names second?

The solution:

names = ['Jenny', 'Alexus', 'Sam', 'Grace']
dogs_names = ['Elphonse', 'Dr. Doggy DDS', 'Carter', 'Ralph']

names_and_dogs_names = zip(names, dogs_names)
list_of_names_and_dogs_names = list
(names_and_dogs_names)
print(list_of_names_and_dogs_names)

Please note Step 2 is:

Create a new variable named list_of_names_and_dogs_names by calling list() on names_and_dogs_names . Print this new variable .

My code wouldn’t let me proceed to step 2. Can someone please explain why my solution didn’t work for Step 1? I “believe” I produced the same results expected.

Thank you for your time and consideration!

Read the whole thread for a more thorough explanation, but this post in particular describes the root of your problem. Zip/List - Python 3

1 Like

Thank you kindly. My apologies for posting a repeated thread. How can I quickly search the forum for questions that might already be posted? I initially searched the forum to see if this question was posed, and I didn’t see it. It appears you found it rather fast. How did you do it?

The solution worked, and I understand now - Thank you again for your time and consideration.

1 Like

No worries.

I only found it fast because I recalled answering the similar question not that long ago. Searching by topic is one way, but you may not find what you’re looking for without reading through several threads/posts. If I hadn’t happened upon my previous answer relatively quickly, I would have just provided you with a similar explanation.