DEV Community

qkrgksals17
qkrgksals17

Posted on

The way to fix an endless loop

Here is my code that creates endless loop, the line that has *.
Please let me know how to fix this.

# Ask to choice coffee
coffee_choice = input("Enter 1 for jonestown brew and 2 for plymouth jolt: ")
*while coffee_choice != 1 and coffee_choice!= 2:
    print ("Please enter a valid option.\n\n")
    coffee_choice = input("Enter 1 for jonestown brew and 2 for plymouth jolt: ")

# Ask pounds of coffee
pounds = input("Enter the amount of coffee you want to order in pounds: ")
*if type(pounds) != float and type(pounds) != int:
    print ("Please enter a valid option.\n\n")
    pounds = input("Enter the amount of coffee you want to order in pounds: ")

# Ask for States
state = input("Please enter your state: ")
Enter fullscreen mode Exit fullscreen mode

Top comments (0)