Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- volume = int(input())
- hearthstones = 0
- fornites = 0
- overwatches = 0
- others = 0
- for i in range(volume):
- game = input()
- if game == "Hearthstone":
- hearthstones += 1
- elif game == "Fornite":
- fornites += 1
- elif game == "Overwatch":
- overwatches += 1
- else:
- others += 1
- print(f"Hearthstone - { hearthstones / volume * 100:.2f}%")
- print(f"Fornite - { fornites / volume * 100:.2f}%")
- print(f"Overwatch - { overwatches / volume * 100:.2f}%")
- print(f"Others - { others / volume * 100:.2f}%")
- РЕШЕНИЕ С РЕЧНИК И ТЕРНАРЕН ОПЕРАТОР:
- games = {'Hearthstone': 0, 'Fornite': 0, 'Overwatch': 0, 'Others': 0}
- volume = int(input())
- for i in range(volume):
- game = input()
- games[game if game in games else 'Others'] += 1
- for game in games:
- print(f"{game} - {games[game] / volume * 100:.2f}%")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement