bug - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: bug (/thread-12939.html) |
bug - ScriptingNub - Sep-19-2018 Good (for the time being )afternoon! So i would like some help fixing this (probably) easy script - as my user suggests im a scripting nub... (was learning LUA) kind regards, ScriptingNub def add(num1, num2): return num1 + num2 def div(num1, num2): return num1 / num2 def tim(num1, num2): return num1 * num2 def subt(num1, num2): return num1 - num2 def main(): validinput = False while validinput == False: try: num1 = int(input("what is the first number")) num2 = int(input("what is the second number")) operation = input("what is the sign") validinput = True return() if (operation == "+"): print("adding") print(add(num1, num2)) elif (operation == "-"): print("subtracting") print(subt(num1, num2)) elif (operation == "*"): print("multiplying") print(tim(num1, num2)) elif (operation == "/"): print("dividing") print(div(num1, num2)) elif(): print("operation not understood!") main() (also if you have any suggestions please let me know :D) RE: bug - Larz60+ - Sep-19-2018 It would be nice if you gave us a clue as to what doesn't work properly. RE: bug - ScriptingNub - Sep-19-2018 ok ill try getting some info :D there is a supposed "unexpected error" before the if statement - ill send a bit of code with it try: num1 = int(input("what is the first number")) num2 = int(input("what is the second number")) operation = input("what is the sign") validinput = True if (operation == "+"): #supposedly it is infront of the "if" print("adding") print(add(num1, num2)) |