FAQ: Learn Python: Function Arguments - Using Both Keyword and Positional Unpacking

This community-built FAQ covers the “Using Both Keyword and Positional Unpacking” 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 Using Both Keyword and Positional Unpacking

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!

2 posts were split to a new topic: Why does the example use an unpacked keyword parameter before a named one?

2 posts were split to a new topic: How does the function turn **kwargs from variables into strings?

My code works exactly as it is supposed to, print to the console shows appropriate string but CC is not letting me go further, what’s going on?

def remove(filename, *args, **kwargs):
  with open(filename) as file_obj:
    text = file_obj.read()
    for arg in args:
       text = text.replace(arg, '******')            
    for kwarg, replacement in kwargs.items():
       text = text.replace(kwarg, replacement)
    return text  

print(remove("text.txt", "generous", "gallant", fond="amused by", Robin="Mr. Robin"))


What specifically do you mean? Have you passed all three instructions, but the next button remains inactive? Have you passed less than three of the instructions?

I passed first one, second stays red even though in console everything points to the fact that my function indeed worked.

If you open the _test.py file, you can see the problem. The only test is whether your ‘transformed’ text referred to as given is exactly the same as the expected text referred to as answer. If you re-read the last part of instruction one, I think you’ll find the difference.

The hint for the first checkmark on part 12 is very misleading.

text.replace(arg, "") #does nothing
text = text.replace(arg, "") #works

Was scratching my head for 20 minutes trying to figure out what was wrong.


I had the exact same problem. I know the hints don’t always tell you exactly what to do, but in this case it really left me confused.


10 months passed… The confusing hint is still there