Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- food = int(input()) * 1000
- total = 0
- command = input()
- while command != 'Adopted':
- day_food = int(command)
- total += day_food
- command = input()
- if food >= total:
- print(f'Food is enough! Leftovers: {food - total} grams.')
- else:
- print(f'Food is not enough. You need {total - food} grams more.')
- ИЛИ С ПРИСПАДАНЕ ОТ ДАДЕНОТО КОЛИЧЕСТВО ХРАНА:
- food = int(input()) * 1000
- command = input()
- while command != 'Adopted':
- food -= int(command)
- command = input()
- if food >= 0:
- print(f'Food is enough! Leftovers: {food} grams.')
- else:
- print(f'Food is not enough. You need {abs(food)} grams more.')
- ДРУГО РЕШЕНИЕ С ТЕРНАРЕН ОПЕРАТОР:
- food = int(input()) * 1000
- while True:
- command = input()
- if command == 'Adopted':
- break
- food -= int(command)
- print(f'Food is enough! Leftovers: {food} grams.' if food >= 0 else
- f'Food is not enough. You need {abs(food)} grams more.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement