I want to create a a string formatting function that prints first name, last name and age into a sentence.
This is my code:
def my_string_formatting(firstname, lastname, age):
print("Hello, my name is "+ firstname + lastname + "I'm " + str(age))
and this is my input and output target:
| Input | "john" && "doe" && 37 |
+-----------------------+-------------------------------------+
| Expected Output | Hello, my name is john doe, I'm 37.
>Solution :
You can can do this easily using an fstring:
def my_string_formatting(firstname, lastname, age):
print(f"Hello, my name is {firstname} {lastname}, I'm {age}.")