[Solved] Python: How to use a similar operator to “or”/”in” in a list [closed]
[ad_1] I’m not sure if I understand your question correctly. You maybe better off using a dict. >>> testbank = {“question 1”:[“answer1a”, “answer1b”, “answer1c”, “answer1d”], … “question n”:[“answerna”, “answernb”, “answernc”, “answernd”]} >>> testbank[‘question 1’] [‘answer1a’, ‘answer1b’, ‘answer1c’, ‘answer1d’] >>> def validate(answer, question): … if answer in testbank[‘question 1’]: … print ‘Correct!’ … else: … print … Read more