Keyword Arguments
Completed
Write describe(name, age, city="unknown") returning NAME (AGE) from CITY. Read name, age and city (city may be - meaning not given) and call the function with keyword arguments.
Input
Three lines.
Output
One line.
Example
Input
Ada 36 London
Output
Ada (36) from London
Editor
Python
Hints
Keyword arguments can be given in any order: f(age=1, name="x").
Solution explanation
Keyword arguments make calls self-documenting and let you skip optional parameters.
Show solution
def describe(name, age, city="unknown"):
return f"{name} ({age}) from {city}"
name = input()
age = int(input())
city = input()
if city == "-":
print(describe(age=age, name=name))
else:
print(describe(name=name, age=age, city=city))