anton_d

04.number_wars

Feb 13th, 2022 (edited)
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. first_name = input()
  2. second_name = input()
  3.  
  4. first_player_pt = 0
  5. second_player_pt = 0
  6. playing_game = True
  7.  
  8. while playing_game:
  9.     first_player = int(input())
  10.     second_player = int(input())
  11.     if first_player > second_player:
  12.         first_player_pt = first_player - second_player
  13.     elif second_player > first_player:
  14.         second_player_pt = second_player - first_player
  15.     else:
  16.         print('Number wars!')
  17.         while True:
  18.             first_player = int(input())
  19.             second_player = int(input())
  20.             if first_player > second_player:
  21.                 first_player_pt = first_player - second_player
  22.                 break
  23.             elif second_player > first_player:
  24.                 second_player_pt = second_player - first_player
  25.                 break
  26.             else:
  27.                 continue
  28.         playing_game = False
  29.  
  30. if first_player_pt > second_player_pt:
  31.     print(f'{first_name} is winner with {first_player_pt} points')
  32. else:
  33.     print(f'{second_name} is winner with {second_player_pt} points')
  34.  
Add Comment
Please, Sign In to add comment