def is_digit(x):
if type(x) == int:
return True
else:
return False
def main():
shape_opt = input('Enter input >> ')
while not is_digit(shape_opt):
shape_opt = input('Enter input >> ')
else:
print('it work')
if __name__ == '__main__':
main()
So when the user input a value that is not an integer, the system will repeat the input(). Else, it does something else. But it won't work, may I know why?
See Question&Answers more detail:os