55
Εικόνα 26.Όριο αριθμού ερωτήσεων
def get_topic_num_settings(screen, font):
…
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_TAB:
selected = (selected + 1) % len(topics)
elif event.key == pygame.K_RETURN:
#allow only numbers.Those numbers must be between 0-10
if input_for_topic[selected].isdigit():
num_questions = int(input_for_topic[selected])
if 0 <= num_questions <= 10:
selected = (selected + 1) % len(topics)
if selected == 0:
active_input = False
else:
inform_message = "Number of questions must be less than 10"
inform_time = time.time()
else:
inform_message = "You must enter a number"
inform_time = time.time()
…
for i, topic in enumerate(topics):
if input_for_topic[i].isdigit():
num_questions = int(input_for_topic[i])
if 0 <= num_questions <= 10:
num_settings[topic] = num_questions
else:
print(f"Number of questions must be between 0 and 10.")
else:
print(f"Wrong num.")
return num_settings