Skip to content

Instantly share code, notes, and snippets.

@peacher5
Created December 1, 2017 04:58
Show Gist options
  • Select an option

  • Save peacher5/a4ee4cb4ea849b1b2ba27b1f41fae32c to your computer and use it in GitHub Desktop.

Select an option

Save peacher5/a4ee4cb4ea849b1b2ba27b1f41fae32c to your computer and use it in GitHub Desktop.
Lab
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