I want to get keyboard input of 5 numbers and add them to a list and print the list. my code just prints an empty list without letting the user type in anything. how do i append the items into the list given the keyboard input?
def get_pygame_events():
pygame_events = pygame.event.get()
return pygame_events
counter_list = []
key = get_pygame_events()
for num in range(0,5):
for event in key:
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_1:
counter_list.append(1)
if event.key == pygame.K_2:
counter_list.append(2)
if event.key == pygame.K_3:
counter_list.append(3)
if event.key == pygame.K_4:
counter_list.append(4)
if event.key == pygame.K_5:
counter_list.append(5)
if event.key == pygame.K_6:
counter_list.append(6)
if event.key == pygame.K_7:
counter_list.append(7)
if event.key == pygame.K_8:
counter_list.append(8)
if event.key == pygame.K_9:
counter_list.append(9)
if event.key == pygame.K_0:
counter_list.append(0)
print(counter_list)