1# To prompt the user to input an integer we do the following:
2valid = False
3
4while not valid: #loop until the user enters a valid int
5 try:
6 x = int(input('Enter an integer: '))
7 valid = True #if this point is reached, x is a valid int
8 except ValueError:
9 print('Please only input digits')
10