while True:
try:
wd = int(input('How wide would you like your letter to be? (5 - 20): '))
if not (5 <= wd <= 20):
raise Exception("Number is not within 5 - 20 range.")
break
except ValueError:
print("Oops! That was no valid number. Try again...")
break
except Exception as e:
print(e)
break
#if you don't want the program to shutdown every time
#the user inputs something wrong, then
#remove some of the breaks

Here's python 2 code:

while True:
try:
wd = int(input('How wide would you like your letter to be? (5 - 20): '))
if not (5 <= wd <= 20):
raise Exception("Number is not within 5 - 20 range.")
break
except NameError,ValueError:
print "Oops! That was no valid number. Try again..."
break
except Exception, e:
print e
break
#if you don't want the program to shutdown every time
#the user inputs something wrong, then
#remove some of the breaks

Also the previous code does not work well for non-numeric values as it uses input with it's eval functionality and gives confusing error (but maybe difference between python2 and python3 input functions?):

How wide would you like your letter to be? (5 - 20): u
name 'u' is not defined

I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...

Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...