-1

I was building a very basic cli program (about lists & dictionaries but doesn't matter for this question) and when i tested it (to make sure that it would exit when i told it to) it just didn't work

item_list = {}

def main():
    while True:
        print("1 for new key, 0 to exit")
        user_input = input()
        if user_input == 1:
            new_key = input("enter new key")
        elif user_input == 0:
            exit()

main()

every time I enter 0, it just re-prints "1 for new key, 0 to exit"

i tried changing exit() to break and it still gave the same result

does making it an infinite loop interfere from breaking out of the loop?

nuudul
  • 5
  • 3
  • See also: [How to compare the user input that's a string with an integer?](/q/64805398/5958455) – iBug May 21 '22 at 19:39

0 Answers0