Can the dog_years function utilize string formatting to produce the output?



In this exercise, the instructions to create the string returned by the dog_years() function makes it appear like string formatting can be used. How would that be done?


Instead of using string concatenation and the str() function to produce the output, Python’s string formatting can be used. The following code example shows how to produce the desired output.

def dog_years(name, age):
    return "{name}, you are {dog_age} years old in dog years".format(name=name, dog_age=(age * 7))