0

I'm trying to create a function to find out it a (x,y) is in a list and then do something. Even though I know the item (x,y) is in the list, it will not find it.

Here is the code I created:

possibles = [(x,y) for x in range(11) for y in range(11)]

print(possibles)

def if_possible(possibles):
  x = input('Enter row:')
  y = input('Enter col: ')
  item = (x,y)
  if item in possibles:
    print(item)
    possibles.remove(item)
    print(possibles)
  else:
    print('Something went wrong')

if_possible(possibles)

I have tried making item = x, y with out parenthesis but that does not work either. The else print('Something went wrong') anyway.

Here is the output: Image

Are there somebody out there that can see what I did wrong here?

vaultah
  • 44,105
  • 12
  • 114
  • 143
Tinadark
  • 31
  • 5

0 Answers0