Dec-23-2017, 10:49 PM
Doing unnecessary stuff there ezdev.
No need to check type,and is same code use try/except(should not be bare).
Catch the error(ValueError) if input need a integer,and give a message to try again.
If use function can use return,the no need to break out.
Function will only return a number,
No need to check type,and is same code use try/except(should not be bare).
Catch the error(ValueError) if input need a integer,and give a message to try again.
If use function can use return,the no need to break out.
Function will only return a number,
int(input(' '))
or float(input(' '))
def foo(): while True: try: odds_input = int(input('Enter a number: ')) return odds_input except ValueError: print('Sorry please enter a valid number,try again') print(foo())