-
-
Save peacher5/a4ee4cb4ea849b1b2ba27b1f41fae32c to your computer and use it in GitHub Desktop.
Lab
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| n = int(input()) | |
| cards_list = [] | |
| for i in range(n): | |
| cards = input() | |
| cards_list.append(cards) | |
| result_list = [] | |
| for cards in cards_list: | |
| cards = cards.split() | |
| sum = 0 | |
| n = 0 | |
| busted = False | |
| for card in cards: | |
| n += 1 | |
| if card == 'A': | |
| sum += 1 | |
| elif card in 'KQJ': | |
| sum += 10 | |
| else: | |
| sum += int(card) | |
| if sum > 21: | |
| busted = True | |
| break | |
| if sum > 16 or n == 5: | |
| break | |
| if busted: | |
| result_list.append('busted') | |
| else: | |
| result_list.append(sum) | |
| for result in result_list: | |
| print(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment