Hello guys, I am trying to simulate a card game where you have to pick the higher card than the function to win, however I am trying to use a list but everytime I go to run it, this error message comes up:
Traceback (most recent call last): File "script.py", line 80, in <module> print(higher_lower(10, 30)) File "script.py", line 46, in higher_lower if guess > List1: TypeError: '>' not supported between instances of 'int' and 'list'
Below is the example code:
def higher_lower(guess, bet): global money ace = 1 jack = 11 queen = 12 king = 13 List1 = [ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, jack, queen, king] random.choice(List1) #Value = random.randint(1, 10) if guess > List1: money = money + bet return "Congratulations, you have picked the higher card and won!\n" + "You now have £" + str(money) + " in your account." elif guess < List1: money = money - bet return "Unfortunately you haven't picked the higher card and lost this time!\n" + "You now have £" + str(money) + " in your account." else: money return "You have picked a card with the same value as your opponent, it is a tie!\n" + "You now have £" + str(money) + " in your account."
any clue on how to fix it?
Thankyou in advance