Hello World Review Help

I am getting multiple errors while trying to add the (half_my_age) variable to the greeting. It works fine without the half my age part. Is there a rule where you can’t have to variables in a line?

my_age=30 half_my_age=(my_age/2) name= "Dan" greeting= "hello my name is "+name+'' "half my age is"+half_my_age" print(greeting)

File “script.py”, line 4
greeting= "hello my name is “+name+’’ “half my age is”+half_my_age”
SyntaxError: EOL while scanning string literal


No. No such rule. You do have a few syntax errors though. The string literals must begin and end with quotation marks either single or double quotes will do. You must concatenate the variables to the strings using the + operator. You must not put quotes before or after the variable name. If you do both, you’ll have a string literal of the variable name instead of a reference to the value the variable is assigned to. You also cannot use the + operator between instances of a string and a number, so the number must be converted to a string in order to concatenate it to a string. For example:

some_string = "Hello, World!" num = 1024 new_string = some_string + " My favorite number is " + str(num) + "." print(new_string)