I made a program for finding all combinations for numbers from 0 to 3 and number of possible lists is 24 (4! = 24)
import random
number_for_list = 0
number_of_combinations = 0
all_lists = []
list_to_check = []
def a_function():
number_for_list = random.randrange(4) #generate a random number
if len(list_to_check) == 4: #check if 4 different numbers are in the list
if list_to_check in all_lists: #if that list (with 4 numbers) already exists in all_lists remove it and go back to a_function
del list_to_check[:]
a_function()
else: #if that list isnt in all_lists
all_lists.append(list_to_check) #add it to the all_lists
number_of_combinations += 1 #raise number_of_combinations
del list_to_check[:] #delete the list_to_check and go back to a_function
a_function()
elif number_for_list not in list_to_check: #if number_for_list isn't in the list_to_check
list_to_check.append(number_for_list) #add it to the list_to_check and go back to a function
a_function()
elif number_for_list == 24: #if number_of_combinations equals 24 then it should print all lists
print('I found all the combinations') #and stop the function
print(all_lists)
return
a_function()
For some reason nothing happens when I run the program and I can't find any logical errors, what's wrong then?