0
Sintax Error with Else
I'm having a problem. [Python] When I do : else: print("No") The Output is an error of Sintax. How can I fix? The code is: input("") if input: ("dog") print("Now you have got a dog") else print("No")
3 odpowiedzi
+ 3
1) You need to assign input("") to a variable:
x = input()
2) You need to change your if statement's structure:
if x == "dog":
3) You need a colon after your else statement:
else:
4) You need indentation after the if and else statements:
if x == "dog":
print("Now you have a dog!")
else:
print("No.")
+ 2
Can you post a code and put it here? Thanks!
+ 1
But now when I write dog I have No