+ 6
TypeError: can only concatenate str (not "int") to str. Need help here.
def y_family(fname, lname, age): print(fname + " " + lname + " is " + age + " years old") y_family("Wukie", "Stephanie", 23)
4 Answers
+ 6
As long as you go for print() the output, you don't need to do any conversion. Just use a comma to separate all vars and strings like demonstrated in this sample:
def y_family(fname, lname, age):
print(fname, lname, 'is', age, 'years old')
y_family("Wukie", "Stephanie", 23)
+ 4
Convert age into string..as shown below
def y_family(fname, lname, age):
print(fname + " " + lname + " is " + str( age) + " years old")
y_family("Wukie", "Stephanie", 23)
+ 3
Apongpoh Gilbert You need to do str(age) while concatenate with string.
+ 2
Thanks