FAQ: Learn Python: Function Arguments - Passing Containers as Arguments

This community-built FAQ covers the “Passing Containers as Arguments” exercise from the lesson “Learn Python: Function Arguments”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn Python 3

FAQs on the exercise Passing Containers as Arguments

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Hi,

I ran the following code as you mentioned in the lesson:

def takes_many_args(*args):
print(’,’.join(args))

long_list_of_args = [145, “Mexico City”, 10.9, “85C”]

But threw an error:
print(’,’.join(args))
TypeError: sequence item 0: expected str instance, int found

Expected:
“145,Mexico City,10.9,85C”

I’ve had put quotes in the numbers in the list and it works.
long_list_of_args = [“145”, “Mexico City”, “10.9,” “85C”]

I’m not sure whether I’m missing something or misunderstanding a specific concept…

First, please post code in readable form using the </> icon at the middle of the menu bat at the top of the text box you are typing in.

The string method str.join(iter) where iter is an iterable (e.g., a list) will fail if any member of iter is not a string.