student lesson
student lesson 12/12/22
from time import time
time()
from turtle import *
oogway = Turtle()
from math import ceil
ceil(10.4)
import random
def coinflip():
roi = random.randrange(2)
if roi == 0: print("tails")
else: print("heads")
coinflip()
i = 0
deck = []
hand = [['clubs', 'ace'], ['clubs', 'jack'], ['clubs', 'queen'], ['clubs', 'king'], ['clubs', '10']]
flush = ['10', 'jack', 'queen', 'king', 'ace']
r = False
o = False
y = False
a = False
l = False
f = False
for n in ["hearts", "clubs", "spades", "diamonds"]:
for c in ["ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "jack", "queen", "king"]:
deck.append([n, c])
print(deck)
print(len(deck))
#while i < 5:
# t = random.randrange(len(deck))
# hand.append(deck[t])
# i += 1
print(hand)
for n, c in hand:
for j in flush:
if c == j: # something wrong right here
if r == True:
if o == True:
if y == True:
if a == True:
l = True
else:
a = True
else:
y = True
else:
o = True
else:
r == True
if hand[0][0] == hand[1][0] and hand[2][0] and hand[3][0] and hand[4][0]:
f = True
if r and o and y and a and l and f:
print("royal flush")
print(r)
print(o)
print(y)
print(a)
print(l)
print(f)
Something went wrong in the code above and I don't know what. In the area that I marked above, it's supposed to compare the hand to a royal flush, and if their the same, it changes a variable from false to true. I made the hand a royal flush to test if it works. Some sort of error happens when it's comparing the hand and a royal flush and it never changes the variables to true. There's some hinted code that I made a hint so that it wouldn't interfere with my tests, the code makes the hand random.