Skip to content

Instantly share code, notes, and snippets.

@The-XSS-Rat
Created March 12, 2022 22:07
Show Gist options
  • Save The-XSS-Rat/290ba80de37cbd5fef4d5c4369302341 to your computer and use it in GitHub Desktop.
Save The-XSS-Rat/290ba80de37cbd5fef4d5c4369302341 to your computer and use it in GitHub Desktop.
import random
# utytyur6ryt
def printRand():
return random.randint(1, 11)
# The XXS noob
def drawNew(a, b):
if (a + b > 21):
return "GAME OVER"
else:
return a + b
def die(error):
print(error)
quit()
def main():
userTotal = 0;
dealerTotal = 0;
ans = 1;
print("You can not go over 21 or you lose, you have to have more than the dealer to win.")
# users turn, ask for input until lose or until user stops
userTotal = drawNew(userTotal, printRand())
print("User total: " + str(userTotal))
while (ans == 1):
print("\nSelect option:")
print("--------------")
print("1. Add another random number.")
print("2. Dealer game.\n")
ans = int(input("my option: "))
userTotal = drawNew(userTotal, printRand())
if (userTotal == "GAME OVER"):
die("THE DEALER WINS! His total: " + str(dealerTotal) + " While you had: " + str(userTotal))
else:
print("New total: " + str(userTotal))
# Dealers turn, keeps drawing until 18 or more
while (dealerTotal < 18):
print("dealer total:" + str(dealerTotal))
dealerTotal = drawNew(dealerTotal, printRand())
if (userTotal == "GAME OVER"):
die("YOU WIN! His total: " + str(dealerTotal) + " While you had: " + str(userTotal))
else:
print("New total" + str(dealerTotal))
if(dealerTotal>userTotal):
die("THE DEALER WINS! His total: " + str(dealerTotal) + " While you had: " + str(userTotal))
else:
die("YOU WIN!")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment