I'm trying to make code that checks if the letter the user pressed was the first letter of any word in a list of strings using pygame, the list is generated by urrlib importing from a web page then I have code as follows to check pygame.init() pygame.display.set_mode((100, 100))
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
if event.type == pygame.KEYDOWN:
if x[str(event.key)] in [i[0] for i in final]:
return('Forward')
else:
return 'nope', final
but when I run the code it only prints 'nope' and an empty list, I tried wrapping it in a function and calling it afterwards but I got the error TypeError: 'Function' object has no attribute getitem
Note: final is the list of words and x is a dict referring to the value of each letter since event.key returns an int id