Tell us what’s happening:
I’m trying to do a Python’s poker program, but I’m having an issue with changing cards(probably due to suits and suits_name). My idea was prining the cards with suits symbol, but changing them by typing suits name(as 2 of hearts, 5 of clubs…). There’s a way to give cards the suits value (hearts) but print them with symbol only?
And one more question: I’m a beginner with programming and I’m trying to coding this by myself. Do you think it’s an acceptable code? (It’s obviously not finished)
Your code so far
import random, time
suits = ["♥️", "♦️", "♣️", "♠"]
hearts, diamonds, clubs, spades = suits
suits_name = (hearts, diamonds, clubs, spades)
value = (10, 11)
A = value[0]
J = value[1]
Q = value[1]
K = value[1]
number = [A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K]
def start():
play = input("You wanna play? ")
if play.lower() in ("yes", "sure", "yeah"):
unique_cards = set()
while len(unique_cards) < 5:
unique_cards.add(f"{random.choice(number)}{random.choice(suits_name)}")
cards = list(unique_cards)
print("Your cards are:", ", ".join(cards) )
time.sleep(4)
while True:
change_cards = input("Want to change cards? ")
if change_cards.lower() == "yes":
quantity = input("Which cards? ")
if quantity.lower() == "none":
print("chepalle")
break
elif quantity.lower() in cards:
cards.remove(quantity.lower())
new_cards = [f"{random.choice(number)}{random.choice(suits_name)}" for _ in range(len(quantity.split(',')))]
cards.extend(new_cards)
print("Your new cards are: ", ", ".join(cards))
break
elif quantity.lower() == "all":
all_choice = [f"{random.choice(number)}{random.choice(suits_name)}" for _ in range(5)]
print("Your new cards are: ", ", ".join(all_choice))
break
else:
print("Invalid cards selected")
elif change_cards.lower() == "no":
break
# CONTROLLARE CARTE CON IPOTETICO AVVERSARIO/AVVERSARI
print("ngul")
else:
exit()
start()