Остановка цикла while при выполнении условия в списке пользовательских входов - PullRequest
0 голосов
/ 03 июня 2018

Пожалуйста, я пытаюсь создать регистр, который добавляет к списку, который вводит пользователь, прерывает и возвращает к приглашению пользователя «ввести данные», но останавливается только тогда, когда вводится строка «done».

userinput = input("Please Input price: ")
price = [userinput]

    while True:
       if price.append(userinput) is True:
        print(price)
       if price.append("done") is True:
        break

    print(price)

1 Ответ

0 голосов
/ 03 июня 2018
userinput = input("Please Input price: ")
price = []

while userinput != "done":
    price.append(userinput)
    print(price)  # This appears to serve as debugging only, you will see the whole list as it is grown
    userinput = input("Please Input price: ")

print(price)
...