basically I'm creating a small lotto program and I want to do a function where the user would enter his/ or her id and it will give their numbers and lets them know if they are a winner
The players numbers are stored in a 2D array**(not a numpy)** like this [[2, 17, 19, 19, 21, 29, 8, 17],[9, 5, 17, 18, 23, 28, 2, 2]] so if a player enters their id as 1 then it should return the second array completely, As I want to check if that player is a winner or not.
I have done the below but it doesn't work, the player checking part does work when I run it separately
IndexError: list index out of range
player = [[2, 17, 19, 19, 21, 29, 8, 17],[9, 5, 17, 18, 23, 28, 2, 2],[5, 8, 18, 18, 29, 30, 25, 26],[5, 6, 15, 13, 23, 24, 12, 12]]
win = [2, 17, 19, 19, 21, 29, 8, 17]
group1 = set(win[0:6])
group2 = set(win[6:8])
playerID = int(input("Please enter player ID "))
print(playerID)
print(player[playerID])
for i in player[playerID]:
count = 0
for j in range(6):
x = player[i][j]
if x in group1:
count+=1
print("score")
if j == 5:
if count == 6:
print("You are a winner")
elif count == 5:
print("You win with 5 numbers" )
elif count == 4:
print("You win with 4 numbers")
elif count == 3:
print( "you win with 3 numbers")
elif count < 3:
count2 = 0
for l in range(6,8):
y = player[i][l]
if y in group2:
print("you win with bouns numbers")
else:
print("sorry you lose")