Solution: Generate a List of Questions and Possible Answers
Learn how to write a function to generate a list that contains questions from a list and its four possible answers from another list.
We'll cover the following...
The solution to the problem of generating a list that contains questions and their four possible answers from another list is given below.
Solution
Press + to interact
def listAQ(qlist, alist):qalist = [ ]for q, a in zip(qlist, alist) :lst = [q, *a]qalist.append(lst)return qalistqlist = ['What is the capital of England?', 'Which is your favorite color?']alist = [['Delhi', 'London', 'Islamabad', 'New York'], ['Red', 'Blue', 'White', 'Black']]print(listAQ(qlist, alist))