To return something from a function we add the return
keyword followed by the value to return, like here with return label
.
def age_label(age):
label = "User age: " + age
return label
A function can return any type of value, like a string, integer, float, or boolean. This function returns the number value inside result
.
def times_ten(number):
result = number * 10
return result
We can use the return value of a function like any value by calling the function. Here, we call age_label("22")
to use its value.
def age_label(age):
label = "User age: " + age
return label
print(age_label("22"))