I have a list, and I'm asking the user to insert some words into a list. I compare the words he entered and check if they exist in the first dictionary (if not, I remove that word).
Now, I want to have each words he inputed on the specific day. (for example, in the first iteration, id he enters test1 test2
I should have a dictionary like 0: test1 test2
and for the second iteration if he enters test0
to ONLY have 1: test0
.
The problem is that at the second iteration I get everything: 1: test1 test2 test0
. How can I fix this ?
import itertools
my_list1 = []
my_first_list = ["test", "test1", "test2"]
zile_muschi = {}
for i in range(0, 2):
day = str(input("Day" + str(i) + "(spaces between words):"))
my_list1.append(day)
combined = list(itertools.chain(*map(str.split, my_list1)))
for element in combined:
if element not in my_first_list:
print("Word: " + element + " is not correct!")
combined.remove(element)
zile_muschi[i] = combined
print(zile_muschi)