I am trying to write a program that outputs a list of questions for a test. What I am trying to do is to avoid adding duplicates to the list that way when I print the list I only have a certain amount of unique elements.
def pick_questions(input_list, number_of_picks):
"""Picks random elements of an input list given the number of picks"""
selected_strings = []
for index in range(0, number_of_picks + 1):
random_index = randint(0, len(input_list) - 1)
if input_list[random_index] not in selected_strings:
selected_strings.append(input_list[random_index])
random_index = randint(0, len(input_list) - 1)
return selected_strings