The way to fix an endless loop

qkrgksals17

qkrgksals17

Posted on November 21, 2017

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
πŸ’– πŸ’ͺ πŸ™… 🚩
qkrgksals17
qkrgksals17

Posted on November 21, 2017

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related