目前我的代码非常简单
export
但是对于#BlackJack
print("welcome to Wasteful's blackjack game")`
print("this program was built using standard python")
print("please select a option")
print("A to start, B to quit")
print("----------------------------")
menu_select = input("A/B: ").lower
if menu_select == "a":
print("starting game when i can be assed to program it")
elif menu_select == "b":
exit()
else:
print("invalid")
和a
都返回空白吗?我被困住了,可能需要一点帮助,谢谢!
编辑:我注意到.lower中应该是.lower()的愚蠢错误
答案 0 :(得分:0)
这是因为您没有调用lower()
,而是将menu_select
设置为函数本身 :
>>> menu_select = input("? ").lower
?
>>> menu_select
<built-in method lower of str object at 0x10ca5eab0>
将行更改为:
menu_select = input("A/B: ").lower()
答案 1 :(得分:0)
def main():
print("welcome to Wasteful's blackjack game")
print("this program was built using standard python")
print("please select a option")
print("A to start, B to quit")
print("----------------------------")
menu_select = input("A/B: ").lower()
if (menu_select == "a"):
print("starting game when i can be assed to program it")
elif (menu_select == "b"):
exit()
else:
print("invalid")
main()
首先,就像rassar所说的那样,您必须在从用户那里得到输入后调用.lower()。 接下来,我总是发现创建一个主循环函数来调用所有将来的函数并使代码保持整洁更容易!希望这有所帮助! 编码愉快! :)