I am trying to make it that the user will get an error message back if they enter alphabetical letters or non-integer numbers, and when an integer is entered the program will proceed to show this integer number being squared and cubed. My teacher doesn't want any 'breaks' in code or any ValueErrors.
print("Squaring and cubing integer program has started") #Introduction of program for user
UserNumber=input("Enter an integer to be raised to the power of 2 and 3: ") #Asks user to input an integer, that will then be raised to the power of 2 and 3
while '.' in UserNumber or UserNumber.isalpha(): #Error-trap to test if input contained letters of the alphabet or contains decimal point
print("You have not entered an integer. Try again and enter an integer!") #Alert for user to inform that their entry was invalid (not an integer)
UserNumber=input("Enter an integer to be raised to the power of 2 and 3: ") #Asks user again to enter an integer, if they did not previously.
print(int(UserNumber), " is the integer you entered.") #Displays to user their inital integer
print(int(UserNumber), " squared is ", int(UserNumber)**2) #Displays to user their input integer squared
print(int(UserNumber), " cubed is ", int(UserNumber) **3 ) #Displays to user their input integer cubed
print("Calculations are now finished.") #Output to show program has ended