This is what I have so far:
userNum = int(input('How many perfect numbers do you wish to sum? (1-4)'))
while userNum != 1 and userNum != 2 and userNum != 3 and userNum != 4:
userNum = input('You did not enter a number 1-4! Try again!')
if userNum == 1:
print('Sum is 6 = 6')
elif userNum == 2:
print('Sum is 6 + 28 = 34')
elif userNum == 3:
print('Sum is 6 + 28 + 496 = 530')
elif userNum == 4:
print('Sum is 6 + 28 + 496 + 8128 = 8658')
If I enter a number that is not 1,2,3, or 4 it does re-prompt but it won't exit the while loop if I then enter one of the specified integers. Any advice?