Dec-18-2019, 05:52 AM
(This post was last modified: Dec-18-2019, 06:09 AM by jusrosetyler1123.)
i have a program that im working on to emulate a number of clicks over a user defined amount of time with a user defined delay seperation. im working on error checking for the variable type
heres the relevant code
i get an error of UnboundLocalError
also i forgot in global scope
heres the relevant code
def get_time(): print("enter 1 for seconds") print("enter 2 for minutes") print("enter 3 for hours") timeTyp = input("please enter one of the coresponding numbers> ") timeLen = input("please enter how long you want to run> ") timeDel = input("please enter how long you want the delay between clicks in miliseconds or d for default> ") try: timeTyp = int(timeTyp) timeLen = int(timeLen) try: timeDel = float(timeDel*1000) except ValueError: if(timeDel.lower().strip(" ") == "d"): td = 1.0 else: err = True if(timeTyp == 1): tl = timeTyp elif(timeTyp == 2): tl = timeTyp * 60 elif(timeTyp == 3): tl = timeTyp * 3600 if(err == True): raise ValueError except ValueError: print("invalid input. try again") tl, td = get_time() return tl, tdwhat am i doing wrong
i get an error of UnboundLocalError
also i forgot in global scope
err = False