Why is this invalid syntax | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

Why is this invalid syntax

name=input("enter a name:") if your name=="mohamed": print("hello the praised one") else: print("oh hello")

5th Sep 2020, 8:56 PM
asavtripple6
asavtripple6 - avatar
7 Respostas
+ 3
"your" is not a keyword, builtin, or instatiated variable. I am pretty sure you got an error message saying something similar.
5th Sep 2020, 9:00 PM
Steven M
Steven M - avatar
+ 3
The name of the variable is "name" so in line 2 why have you changed it to your name It wil give an error varible undefined Remove "your"
5th Sep 2020, 9:01 PM
Nilesh
+ 2
What is "your"? if name=="mohamed":
5th Sep 2020, 8:56 PM
Steven M
Steven M - avatar
+ 1
Oh thx
5th Sep 2020, 9:02 PM
asavtripple6
asavtripple6 - avatar
+ 1
So much it works now
5th Sep 2020, 9:03 PM
asavtripple6
asavtripple6 - avatar
0
What do you mean
5th Sep 2020, 8:58 PM
asavtripple6
asavtripple6 - avatar
0
This is python
5th Sep 2020, 8:58 PM
asavtripple6
asavtripple6 - avatar