exception - showing result of try except integer check as a string -
i need function check different user input variables integers. results should confirmed user @ end. check works in keeps looping until integer typed in, cannot results display...
def chkint(msg): while true: try: n = input(msg) return(int(n)) except valueerror: print("please enter actual integer.") number1 = input (chkint("please enter first value:")) number2 = input (chkint("please enter second value:")) results = (number1, number2) print ("i have accepted: " + str (results))
no answer, played , hey presto, works...
def chkint(msg): while 1: try: n = input(msg) return(int(n)) except valueerror: print("please enter integer.") number1 = chkint("please enter first value:") number2 = chkint("please enter second value:") results = [number1, number2] print ("i have accepted: " + str (results))
Comments
Post a Comment