Python Variable Name gives Syntax Error | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Python Variable Name gives Syntax Error

So, I am trying to make a code that can display your phone number, but for some reason my variable name is giving a syntax error and I tried looking for a reason. Here is the example: print("What is the first 3 digits in your phone number?"), end=(' ') first_3 = input() print("What is the second 3 digits in your phone number?", end=(' ') second_3 = input() print("What is your last 4 digits in your phone number?", end=' ') last_4 = input() print(f"Your number is {first_3 }-{second_3}-{last_4}") The variable name,"first_3" gives a syntax error.

27th Jul 2020, 9:42 PM
Jordan
Jordan - avatar
2 Answers
+ 2
Your parentheses are over the place. Check your print lines again. It has to go like this: print('whatever', end=' ')
27th Jul 2020, 10:08 PM
HonFu
HonFu - avatar
0
Copy it playground and save the code link here.. In python, every statement with extra space may cause you different output or error... And your not closing print function there...
27th Jul 2020, 9:50 PM
Jayakrishna 🇮🇳