spam = {"age":"25", "name":"Frank"} def eggs(**kwargs): name = kwargs.get('name', 'Initial Name') age = kwargs.get('age', 'Initial Age') print("Name:" + name) print("Age:" + age) eggs(**spam) spam = {"name":"Frank"} eggs(**spam)
Output:Name:Frank
Age:25
Name:Frank
Age:Initial Age
>>>
It's better to use f-strings or str.format() method
print(f"Name: {name}") print("Age: {}".format(age))in this case age can be a number and you don't need to cast it as str in order to use in concatenation
spam = {"age":25, "name":"Frank"} def eggs(**kwargs): name = kwargs.get('name', 'Initial Name') age = kwargs.get('age', 'Initial Age') print(f"Name: {name}") print(f"Age: {age}".format(age)) eggs(**spam)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs