Question: attempts = 0 while attempts < 3 : miles = float ( input ( ' Enter how many miles you want converted: ' ) )

attempts =0
while attempts <3:
miles = float(input('Enter how many miles you want converted: '))
if miles <0:
print("You cannot enter a negative number. Goodbye, William.")
attempts+=1
else:
milesToKilometers = miles *1.6
print(f"{miles} Miles is equal to {milesToKilometers:,.2f} Kilometers. Amazing!")
if attempts ==3:
print("Error: You have entered an invalid value three times in a row. Program terminated.")
Redesign the solution using functions for the above program with :
1. define a function named main()
2. get input in the main function and pass it to the following functions:
a. milesToKm()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!