Advertisement
BbJLeB

04. Darts

May 16th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.17 KB | None | 0 0
  1. # 04. Darts
  2. name = input()
  3. command = input()
  4. type = ''
  5. score = 301
  6. shots_counter_success = 0
  7. shots_counter_unsuccess = 0
  8.  
  9. while command != "Retire":
  10.     type = command
  11.     reached_score = int(input())
  12.     if command == "Single":
  13.         if reached_score <= score:
  14.             score -= reached_score
  15.             shots_counter_success +=1
  16.         else:
  17.             score = score
  18.             shots_counter_unsuccess +=1
  19.     elif command == "Double":
  20.         total_score = 2*reached_score
  21.         if total_score <= score:
  22.             score -= total_score
  23.             shots_counter_success += 1
  24.         else:
  25.             score = score
  26.             shots_counter_unsuccess += 1
  27.     elif command == "Triple":
  28.         total_score = reached_score * 3
  29.         if total_score <= score:
  30.             score -= total_score
  31.             shots_counter_success += 1
  32.         else:
  33.             score = score
  34.             shots_counter_unsuccess += 1
  35.     if score == 0:
  36.         print(f"{name} won the leg with {shots_counter_success} shots.")
  37.         break
  38.     command = input()
  39. if command == "Retire":
  40.     print(f"{name} retired after {shots_counter_unsuccess} unsuccessful shots.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement