Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
bug
#1
Good (for the time being Big Grin )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 LOL

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)
Reply
#2
It would be nice if you gave us a clue as to what doesn't work properly.
Reply
#3
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))
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020