Advertisement
Spocoman

Football Results

Feb 22nd, 2022 (edited)
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. won = 0
  2. lost = 0
  3. drawn = 0
  4.  
  5. for i in range(3):
  6.     game = input()
  7.     if game[0] > game[2]:
  8.         won += 1
  9.     elif game[0] < game[2]:
  10.         lost += 1
  11.     else:
  12.         drawn += 1
  13.  
  14. print(f"Team won {won} games.")
  15. print(f"Team lost {lost} games.")
  16. print(f"Drawn games: {drawn}")
  17.  
  18.  
  19. РЕШЕНИЕ С РЕЧНИК И ТЕРНАРЕН ОПЕРАТОР:
  20.  
  21. result = {'won': 0, 'lost': 0, 'drawn': 0}
  22.  
  23. for i in range(3):
  24.     game = input()
  25.     result[{game[0] > game[2]: 'won', game[0] < game[2]: 'lost', game[0] == game[2]: 'drawn'}[True]] += 1
  26.  
  27. print(f"Team won {result['won']} games.")
  28. print(f"Team lost {result['lost']} games.")
  29. print(f"Drawn games: {result['drawn']}")
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement