for reference im using python 3.6 im trying to format a variable so that if you
ID: 3817730 • Letter: F
Question
for reference im using python 3.6
im trying to format a variable so that if you print it, it comes out as a question in a specific format.
sample code:
question1=(question_list[0]+" "+"A)"+answer_list[0]+" "+"B)"+answer_list[1])
when i print question1 i get:
"question_list[0]+" "+"A)"+answer_list[0]+" "+"B)"+answer_list[1]. where the "/n" does not create a new line
what i need is:
question_list[0]
A)answer_list[0]
B)answer_list[1]
im just not sure how to format the variable before i run the print function.
any help would be grealtly appreciated
Explanation / Answer
sample code:
import os
import sys
import numpy as np
question_list = ["what is your name?","what is your age?"]
answer_list = [["ankit","amit","mark","zucky"],[1,2,3,4]]
print question_list[0]+" A)"+ answer_list[0][0]+" B)"+ answer_list[0][1]+" C)"+ answer_list[0][2]+" D)"+ answer_list[0][3]
samplle output:
what is your name?
A)ankit
B)amit
C)mark
D)zucky
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.