0
Question
Hello everyone, I am new to python and coding in general. I really like SoloLearn as it's actually pretty good at teaching and the community from what I've seen so far is really nice. I am practicing writing random code and I don't really understand the error. age = 21 name = input('Enter your girlfriends name:') print(' Hello, ' + name) print("Hello my name is " + name) print("I am" + str(age) "years old") I tried writing the code to produce- I am 21 years old. But I get this: File "file0.py",line 15 print("I am" + str(age) "years old") ^ SyntaxError: invalid syntax Any helpful comments or advice would be highly appreciated.
3 Answers
+ 2
You forgot the + in between str(age) and "years old"
P. S.:
you can do it also like this:
print("I am", age, "years old")
and like this:
print(f"I am {age} years old")
Keep experimenting and learning!
+ 2
You should be typing
print("I am" + str(age) + "years old")
You forgot a plus there for combining the strings
+ 1
You forgot to put + in the third print statement by the way you can use , instead of + aswell.
correction
age = 21
name = input('Enter your girlfriends name:')
print(' Hello, ' + name)
print("Hello my name is " + name)
print("I am" + str(age) + "years old")