+ 2
Can anyone help me with if statement?
Name= input () If Name : Solly print ( Name) I tried this š and gave input as Solly but it is giving me an error . Can anybody explain me what is the mistake done by me . I will be thankful for the explanation š
4 Answers
+ 3
Name : Solly => Solly is not declared variable still so error unknown Solly.
What are you trying by this statement? invalid it is.
Do you checking input is "Solly" ? Then do like
if Name == "Solly" : #comparing
print( Name )
Add else part to other case like
else :
print ( "Input is : " Name)
+ 2
Solly
That is not a write syntax. Learn about syntaxes first.
+ 2
In this case Solly is a string. Use " " for it. And ":" is not true. When you want to say "if something is equal to something else" you should use "=="
It means your code should be like:
Name = input()
If Name == "solly" :
Print("your name is solly)
else:
Print("your name is not solly")
#for example
+ 1
Hey Solly, I just checked your script. May be this one is which fix your problem?
Name = input ()
if Name == "Solly":
print ("Your name is: "+Name)
else:
print("Another Name")
It works for me. Prints "Your name is: Solly" or "Another Name" if you give different input than Solly