I was trying to prompt input for option and validate the input number. Below are the codes and I seperated into two different function, how can I make this into one function ? perhaps using return ?
def again(option): if option == 1: print("one") elif option == 2: print("two") else: print("Invalid number !") retry = int(input("Retry number: ")) if retry == 0: print("return mainpage") else: while retry > 3 and retry < 0: retry = int(input("Retry number: ")) if retry == 0: print("return mainpage") else: again(retry) def test(): option = int(input("Please enter your choices: ")) again(option) test()
https://stackoverflow.com/questions/67310175/how-to-utilize-return-between-function April 29, 2021 at 10:17AM
没有评论:
发表评论