I'm new to python so if my card looks very beginner-ish that is why.
I'm trying to compare two cards and find which one is bigger. In this scenario, red beats black, yellow beats red and black beats yellow (like a digital rock paper scissors) I also intend on comparing the numbers of the cards if the suits / colours are the same
This is what I've got so far:
import random
vals = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
colours = ['red', 'yellow', 'black']
deck = list(itertools.product(vals, colours))
random.shuffle(deck)
for vals, colours in deck:
print( str(vals) + ' ' + str(colours))
p1card = str(deck[0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28])
p2card = str(deck[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29])
print(player_one + "'s card = " + str(p1card))
print(player_two + "'s card = " + str(p2card))
if p1card.find('red') and p2card.find('black'):
print(player_one + ' wins!')
if p1card.find('yellow') and p2card.find('red'):
print(player_one + ' wins!')
if p1card.find('black') and p2card.find('yellow'):
print(player_one + ' wins!')
if p2card.find('red') and p1card.find('black'):
print(player_two + ' wins!')
if p2card.find('yellow') and p1card.find('red'):
print(player_two + ' wins!')
if p2card.find('black') and p1card.find('yellow'):
print(player_two + ' wins!')
When I run the code I get the error:
TypeError: list indices must be integers or slices, not tuple
I dont know what this means or how I'm going to even do this task so any help would be very appreciated!
Thanks!