Сейчас я учусь в школе и прохожу курс Python. В этой лаборатории меня просят создать цикл, который выводит вводимые пользователем данные в предложение до тех пор, пока пользователь не введет команду «Выход».
Пример: если ввод:
apples 5
shoes 2
quit 0
вывод:
Eating 5 apples a day keeps the doctor away.
Eating 2 shoes a day keeps the doctor away.
мой код:
your_input = input() #input string and int
string_value = your_input.split()
str_value = string_value[0]
int_value = string_value[1]
while 'quit' not in your_input:
print("Eating {} {} a day keeps the doctor away.".format(int_value,str_value))
your_input = input()
break
Вывод:
Eating 5 apples a day keeps the doctor away.
когда это должно быть:
Eating 5 apples a day keeps the doctor away.
Eating 2 shoes a day keeps the doctor away.
используя ввод:
apples 5
shoes 2
quit 0
Подробнее здесь: https://stackoverflow.com/questions/787 ... while-loop