I want to check that the random cards from the list are not the same card. How can I do that? Can you help me? Thanks.
import random
vals = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']
suits = ['C', 'D', 'H', 'S']
name = []
playercount=int(input("Please Enter Number of Player = "))
if 2 <= playercount <= 5:
for i in range(playercount):
username=str(input("Please Enter Player Name: "))
if not username:
name.append("Player {}".format(i+1))
name.append(random.choices(vals))
name.append(random.choices(suits))
else:
name.append(username)
name.append(random.choices(vals))
name.append(random.choices(suits))
print("Players, Vals and Suits on the Desk ")
for x in range(len(name)):
print (name[x])
else:
print("Try Again")
source https://stackoverflow.com/questions/71697983/how-to-prevent-receiving-the-same-random-data-from-the-list-in-python
Comments
Post a Comment