I have a dictionary like this:
questions ={
'1.Who is Satoshi Nakamoto' : {'answers':{'right_answer':'Pseudonym','wrong_answer':['Bill Gate', 'Elon Musk', 'Warren Buffet']}},
'2.Who is richest' : {'answers':{'right_answer':'Pseudonym','wrong_answer':['Bill Gate', 'Elon Musk', 'Warren Buffet']}}
}
Based on the dictionary, I want to print the questions and the option values.
This is the code I used:
for question in q:
print(question)
answers =([questions[question]['answers']['right_answer']] +questions[question]['answers']['wrong_answer'])
for answer in answers:
print(answer)
This produces a result like:
1.Who is Satoshi Nakamoto
Pseudonym
Bill Gate
Elon Musk
Warren Buffet
2.Who is richer
Pseudonym
Bill Gate
Elon Musk
Warren Buffet
But I want to print the options with bullet headers A, B, C, D, etc. like this:
1.Who is Satoshi Nakamoto
A.Pseudonym
B.Bill Gate
C.Elon Musk
D.Warren Buffet
2.Who is richer
A.Pseudonym
B.Bill Gate
C.Elon Musk
D.Warren Buffet
Maybe someone could help me this. Thank you so much!
q?f-strings,enumerate,ord, andchrin that order. Practice with each and you can do what you want.zipandstrings.ascii_uppercase. (I doubt you have more than 26 answers per question.)