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")

7th Feb 2018, 12:35 PM
D3n1
D3n1 - avatar
3 Answers
+ 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.")
7th Feb 2018, 1:17 PM
LunarCoffee
LunarCoffee - avatar
+ 2
Can you post a code and put it here? Thanks!
7th Feb 2018, 6:07 PM
LunarCoffee
LunarCoffee - avatar
+ 1
But now when I write dog I have No
7th Feb 2018, 1:34 PM
D3n1
D3n1 - avatar