Related to a previous post, I am trying to make a card game and i want two things to happen, I want the User to decide how many players are playing the game, and then i want it to deal the correct amount of cards to the amount of players, then move on to the next round.
## this creates our deck of cards ##
deck = []
suites = ['hearts', 'diamonds', 'spades', 'clubs']
value = [2,3,4,5,6,7,8,9,10,'Jack','Queen','King','Ace']
for s in suites:
for v in value:
deck.append([v, s])
def oh_hell_yeah():
o = 1
d = 10
f = True
while f == True:
## this designated how many players are actually playing ##
for p in range(int(input("how many players?"))):
print("player " + str(o) + " got")
random.shuffle(deck)
for i in range(d):
card = print(deck[i][0], "of", deck[i][1])
o += 1
d -= 1
## this is to make sure the round moves on, it starts at 10 cards, then 9, then 8, etc ##
##lets say there's 2 players, if i dont include the below code, it deals cards to both players just fine,
##but with the below code, it deals to player 1, then player 2 with the reduced cards, and then it ends
if input('next round?') == ('yes' or 'y'):
f = True
else:
f = False
oh_hell_yeah()
this is what I tried to make and as my comments explain, if i have 2 players, the second player gets ignored for the first "round" and then gets dealt less cards. how would i go about fixing this?
I assume you're a kid or something and it's kind of hard to tell what you're asking, but I'll try to point out some obvious errors:
print.printis for displaying stuff, but it doesn't actually have any value. You want to assign to a string instead, and then print the string, like so:Note that the
str()is needed because the value can be an int (but only sometimes: it would be better if yourvaluelist was either all ints or all strings, but eh whatever).First of all, you are not using
orin the correct way. You should assign a variable to your input first, and then check if it's equal to "yes" or "y", like this:Second, throw out the
fvariable and use abreakinstead.breakends the loop.Lastly, the reason you never get to the second player's turn is because you're asking to move onto the next round before the for loop is even finished looping once. To fix this issue, unindent this part of your code so that it is no longer in the for loop. It should be in the while loop, but not in the for loop.
Best of luck.