list1 = ['physics', 'chemistry', "dog", "cat","dog"];
I want it to say if I typed in an input dog it will tell me dog is the forth one and sixth one.
Use list comprehensions:
list1 = ['physics', 'chemistry', "dog", "cat","dog"]
string = input()
res = [i for i, el in enumerate(list1) if el == string]
print(res)
Output:
[2, 4]