我有问题和答案,它们都是列表,每个都包含 3 个字符串。我必须通过函数在终端中渲染两者render_responses()
我已经尝试了下面显示的代码,但我的尝试似乎都没有成功
QUESTIONS = [
'Please explain your Python, Django and Django Rest Framework experience.',
'What is your favorite feature of Python 3 and when did you use it?',
'What is the most annoying aspect of Django or DRF?'
]
# TODO: Add your answers
ANSWERS = ["I took 2 classes through university both which were taught in python.", "me", "bee"]
def render_responses(questions, answers):
# TODO: Render your responses out to the console
questions = QUESTIONS
answers = ANSWERS
if questions == []:
return("There are no questions")
elif answers == []:
return("There are no answers")
else:
return(questions[0], answers[0], questions[1], answers[1], questions[2], answers[2])
代码编译但只返回 < function render_responses at 0x7fa2b1942b70 > 当我把 print(render_responses)
需要注意的是,在python中,几乎所有东西都是对象。这包括功能。render_responses
是一个函数对象,你在这一行打印它:
print(render_responses)
如果您想调用该函数,请在它后面加上括号并为其提供必要的参数:
print(render_responses(questions, answers))
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句