I have the following script. I ask the user for categories and every category can be sorted in a couple of different ways also given by the user. The output should thus be something like:
{'a': ['b', 'c'], 'd': ['e', 'f']}
But it comes:
{'a': ['b', 'c', 'e', 'f'], 'd': ['b', 'c', 'e', 'f']}
I think that it's because i refer to the same list in each category. I don't really know how to make it dynamic and clearing the list afterwards doesn't seem to give to proper result either.
Can someone point me in the right direction? Thanks in advance
def user_settings():
settings = {}
sorteer = []
while True:
categorie = input('wat wordt de naam van de categorie: \n')
if categorie == 'q':
break
while True:
sorteren = input('waar wil je op sorteren: \n')
if sorteren == 'q':
break
sorteer.append(sorteren)
settings[categorie] = sorteer
print(settings)