Advertisement
exDotaPro

9_march_2019_4_darts

Jan 10th, 2020
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.17 KB | None | 0 0
  1. player_name = input()
  2.  
  3. STARTING_POINTS = 301
  4. scored_points = 0
  5. shot_successful = 0
  6. shot_fail = 0
  7.  
  8. command = input()
  9.  
  10. while command != 'Retire':
  11.     target = command
  12.     shot_score = int(input())
  13.  
  14.     if target == 'Single':
  15.         scored_points = shot_score
  16.         if scored_points <= STARTING_POINTS:
  17.             STARTING_POINTS -= scored_points
  18.             shot_successful += 1
  19.         else:
  20.             shot_fail += 1
  21.  
  22.     elif target == 'Double':
  23.         scored_points = shot_score * 2
  24.         if scored_points <= STARTING_POINTS:
  25.             STARTING_POINTS -= scored_points
  26.             shot_successful += 1
  27.         else:
  28.             shot_fail += 1
  29.  
  30.     elif target == 'Triple':
  31.         scored_points = shot_score * 3
  32.         if scored_points <= STARTING_POINTS:
  33.             STARTING_POINTS -= scored_points
  34.             shot_successful += 1
  35.         else:
  36.             shot_fail += 1
  37.  
  38.     if STARTING_POINTS == 0:
  39.         print(f'{player_name} won the leg with {shot_successful} shots.')
  40.         break
  41.  
  42.     command = input()
  43.  
  44.     if command == 'Retire':
  45.         print(f'{player_name} retired after {shot_fail} unsuccessful shots.')
  46.         break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement