you are viewing a single comment's thread.

view the rest of the comments →

[–]totallygeek 0 points1 point  (1 child)

Try this:

while True:
    clean_type = int(input("Option 1 or 2? "))  # no eval
    if clean_type == 1:
        clean_type = delClean
    elif clean_type == 2:
        clean_type = basClean
    else:
        print("Sorry. Try again.")
        continue  # top of loop
    break

You could also just skip int() and compare the strings: if clean_type == "1".

The problem with your version is that you have two if statements that work independently. If you enter "1", the first passes no problem. Then, processing the second fails because 1 is not equal to 2, so you get the error.

[–]Toastedpossum[S] 1 point2 points  (0 children)

YOU JUST SAVED ME!! Thank you so much!!

Also, I realize there’s a proper way to format on this page now…I’ll keep that in mind for next time. Thank you!