Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

2
Blackjack Beginner Function Confusing Me
Post Body

I'm taking the udemy course called complete python bootcamp from zero to hero in python.

One of the practice problems is to write a function that given three integers between 1 and 11, if their sum is less than or equal to 21, return their sum. If their sum exceeds 21 and there's an eleven, reduce the total sum by 10. Finally if the sum (even after adjustment) exceeds 21, return "BUST".

def blackjack(a,b,c):

...: if sum([a,b,c]) <= 21:

...: return sum([a,b,c])

...: elif 11 in [a,b,c] and sum([a,b,c]) <=31:

...: return sum([a,b,c])-10

...: else:

...: return "BUST"

However, for some reason I can't for the life of me understand the less than or equal to 31 part. They give example inputs of (5,6,7), (9,9,9) and (9,9,11), which result in 18, "bust" and 19 respectively.

why not just write if 11 is in the input and sum is greater than 21?

Are they assuming a max of one ace per hand?

Also, I tried inputting (11,11,10) which returns "bust". I'm no blackjack expert but wouldn't that hand be a soft 12? So couldnt i do <=32 to account for two 11's?

I'm probably overthinking this but its still bugging the F outta me.

Author
Account Strength
90%
Account Age
6 years
Verified Email
Yes
Verified Flair
No
Total Karma
1,745
Link Karma
940
Comment Karma
805
Profile updated: 1 week ago
Posts updated: 8 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
4 years ago