Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- first_player = int(input())
- second_player = int(input())
- command = input()
- while command != 'End':
- if command == 'one':
- second_player -= 1
- if second_player == 0:
- print(f'Player two is out of eggs. Player one has {first_player} eggs left.')
- break
- elif command == 'two':
- first_player -= 1
- if first_player == 0:
- print(f'Player one is out of eggs. Player two has {second_player} eggs left.')
- break
- command = input()
- if command == 'End':
- print(f'Player one has {first_player} eggs left.\nPlayer two has {second_player} eggs left.')
- РЕШЕНИЕ С ТЕРНАРЕН ОПЕРАТОР:
- first_player = int(input())
- second_player = int(input())
- while True:
- command = input()
- if command == 'End':
- print(f'Player one has {first_player} eggs left.\nPlayer two has {second_player} eggs left.')
- break
- else:
- first_player -= 1 if command == 'two' else 0
- second_player -= 1 if command == 'one' else 0
- if first_player == 0 or second_player == 0:
- print(f'Player {"one" if first_player == 0 else "two"} is out of eggs. '
- f'Player {"two" if first_player == 0 else "one"} has {second_player if first_player == 0 else first_player} eggs left.')
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement