FAQ: Function Arguments: *args and **kwargs - Variable number of arguments: **kwargs

This community-built FAQ covers the "Variable number of arguments: **kwargs " exercise from the lesson “Function Arguments: *args and **kwargs”.

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

FAQs on the exercise _Variable number of arguments: **kwargs _

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!
You can also find further discussion and get answers to your questions over in Language Help.

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

Need broader help or resources? Head to Language Help and Tips and Resources. If you are wanting feedback or inspiration for a project, check out Projects.

Looking for motivation to keep learning? Join our wider discussions in Community

Learn more about how to use this guide.

Found a bug? Report it online, or post in Bug Reporting

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!

Hello! While going through this the **kwargs exercise I got a bit confused about how we need the quotes when we call the .get() function to retrieve the values of a keyword argument. It was my understanding that this is just following the dictionary syntax, however what if our **kwargs are numbers? Would we still need to use quotes when using functions to get them? This is what I mean:

def arbitrary_keyword_args(**kwargs): print(kwargs.get('1')) #or would it be print(kwargs.get(1)) arbitrary_keyword_args(1='wowzers', 2=101)

Thanks a lot!

1 Like

There seems to be a mismatch between the instructions and the output required to pass.

#4 Instructs you to print() the food variable and print() the drinks variable but it doesn’t say to print() the order_items. See the following image with the required output from the “HInt”.

This is what is necessary to get the code to pass.

tables = { 1: { 'name': 'Chioma', 'vip_status': False, 'order': { 'drinks': 'Orange Juice, Apple Juice', 'food_items': 'Pancakes' } }, 2: {}, 3: {}, 4: {}, 5: {}, 6: {}, 7: {}, } # print(tables) # Write your code below: def assign_food_items(**order_items): food = order_items.get('food') drinks = order_items.get('drinks') #This it the line that need to be added print(order_items) #This it the line that need to be added print(food) print(drinks) # Example Call assign_food_items(food='Pancakes, Poached Egg', drinks='Water')