Why can I only insert a number and not a name?

Advertisements

Hi I’m new to Python and I’m wondering why I was only able to put numbers and not actual names in this code. When I added name I ran into a SyntaxError.

my_age = 27
half_my_age = 13
greeting = Hi 
name = Max
greeting_with_name = Hi + Max

print("my_age + half_my_age + greeting + name + greeting_with_name")    

>Solution :

Name is a String (Combination of characters) not a number. To Store a string in a variable you need to use double quotes ("") or Single Quotes (”).

In Your Code I think you need to put you HI or name into String like this "HI" or "name" to run you code without any SyntaxError.

I Hope this will help you in your python journey.

Leave a ReplyCancel reply