【发布时间】:2018-11-09 19:51:06
【问题描述】:
我正在尝试编写一个脚本来教我的朋友我掌握的一点 Python 知识,并刷新我自己的记忆。我刚开始,它也没有完成,但是当我试运行它时,什么也没有发生。如何运行函数?
这是我目前的代码:
def mainmenu():
choice = {
'print',
'comments',
'if',
'else',
'and',
'or',
'elif',
'input',
'variables',
'strings',
'def',
'class',
'modules',
}
print("What would you like to learn about?")
for statement in choice():
print("- Type {} to learn about {}".format(statement))
pclass = input(">>>")
if pclass in choice():
return choice[pclass]()
else:
print("Invalid Choice")
另外,在我的 for 选择语句中,我试图让它为集合中的每个字符串重复打印内容;我知道声明可能甚至不在我需要输入的范围内。关于我应该用什么替换它的任何想法?
【问题讨论】:
标签: python-3.x