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
1# Any input taken by python is always taken as a string.
2# To convert it to an integer, we have to wrap input() in int(). Example:
3
4num1 = int(input("Enter a number: "))
5num2 = int(input("Enter another number: "))
6total = num1 + num2
7print(f'Sum: {total}')