0

Why do I get this error someone explain please? Syntax Error - result = str(num1 / num2)

When code is ran i get an Syntax Error highlighting "result". Any suggestions? Thanks in advance. elif user_input == "divide": num1 = float(input("Enter a number: ")) num2 = float(input("Enter another number: ") result = str(num1 / num2) print("The answer is: " + result)

6th Feb 2017, 1:55 PM
P4tryk
P4tryk - avatar
6 odpowiedzi
+ 2
it's highlighting result because you didn't close the previous line.. add ) to the end of num2
6th Feb 2017, 1:57 PM
LordHill
LordHill - avatar
+ 2
#justin your ans is right
6th Feb 2017, 5:39 PM
Rohan Vijayvergiya
Rohan Vijayvergiya - avatar
0
Damn haha thanks a lot.
6th Feb 2017, 2:07 PM
P4tryk
P4tryk - avatar
0
no problem, I've had the same problem many times lol
6th Feb 2017, 2:08 PM
LordHill
LordHill - avatar
0
its first changing num1 & num 2 in string and then dividing . but string cant be devided . so it shows error
6th Feb 2017, 5:27 PM
Rohan Vijayvergiya
Rohan Vijayvergiya - avatar
0
I thought that too Rohan, but it is turning the number after division into a string.. it's wierd, but it works
6th Feb 2017, 5:29 PM
LordHill
LordHill - avatar