Loop_thru_list_Subjects_search_return_Index.py


Sign up Free. Don't forget to check out our challenges, lessons, solve and learn series and more ...


Code Snippet

subjects = ['Biology', 'Chemistry', 'Physics', 'Maths', 'Computing', 'English']

for i in range(len(subjects)):
    print('Room[',i,'] =', subjects[i])

what_subject = input("What Subject do you have next?: ")
print("That subject is assigned to the room: ", subjects.index(what_subject))
                    

Try it yourself