**QUESTION**

Redesign the solution so that some portions of the code are repeated. In lab 3 you validated input to ensure that the user entered inputs within certain values. If the user entered an invalid value, the program terminated. Now you will add a loop such that the user gets three chances to enter a valid value. If the user enters an invalid value more than three times in a row, the program should issue an error message and terminate. CANNOT USE BREAK, EXIT, OR ANYTHING THAT FORCES THE PROGRAM TO TERMINATE.

This is my previous code that I need to alter:

#mitokm

print('Randy, how many miles would you like to convert to
kilometers?')

#Getting Miles Input

mi=float(input())

#Checking For Negative Input

if mi>=0:

#Conversion With Rounding

mitokm=(round(mi*1.6,2))

print('Randy,', mi ,'miles is', mitokm ,'kilometers,
how crazy!')

print('')

#FtoC

print('Randy, how many degrees Fahrenheit would you
like to convert to Celsius?')

#Getting F Input

F=float(input())

#Checking For Input Greater Than 1000

if F<=1000:

#Conversion With Rounding

FtoC=(round((F-32)*5/9,2))

print('Randy,', F ,'degrees Fahrenheit
is', FtoC ,'degrees Celsius, wow!')

print('')

#GtoL

print('Randy, how many gallons would
you like to convert to liters?')

#Getting Gallons Input

g=float(input())

#Checking For Negative
Input

if g>=0:

#Conversion
With Rounding

gtol=(round(g*3.9,2))

print('Randy,', g ,'gallons is', gtol ,'liters, amazing!')

print('')

#LbstoKg

print('Randy, how many pounds would you like to convert to
kilograms?')

#Getting
Pounds Input

lbs=float(input())

#Checking
For Negative Input

if
lbs>=0:

#Conversion With Rounding

lbstokg=(round(lbs*.45,2))

print('Randy,', lbs ,'pounds is', lbstokg ,'kilograms,
astounding!')

print('')

#IntoCm

print('Randy, how many inches would you like to convert to
centimeters?')

#Getting Inch Input

inch=float(input())

#Checking For Negative Input

if inch>=0:

#Conversion With Rounding

inchtocm=(round(inch*2.54,2))

print('Randy,', inch ,'inches is', inchtocm
,'centimeters, how cool!')

#Else Statements To End Program

else:

print('ERROR: Inches input cannot be
negative!')

else:

print('ERROR: Pounds input cannot be negative!')

else:

print('ERROR: Gallons
input cannot be negative!')

else:

print('ERROR: Degree input cannot be
greater than 1000!')

else:

print('ERROR: Miles input cannot be negative!')