else:
hs = raw_input("HIT OR SHAME YOUR FOREFATHERS! (h or s): ").lower()
if h in s:
player.append(rc(cards))
else:
break
无论你选择哪一个,我都会收到一条错误,说h未定义。
答案 0 :(得分:0)
回答@chepner所评论的内容:
hs = raw_input("HIT OR SHAME YOUR FOREFATHERS! (h or s): ").lower()
if hs == 'h':
player.append(rc(cards))
else:
break
或更短:
hs = raw_input("HIT OR SHAME YOUR FOREFATHERS! (h or s): ").lower()
if hs != 'h': break
player.append(rc(cards))
答案 1 :(得分:0)
在您的代码中
hs = raw_input("HIT OR SHAME YOUR FOREFATHERS! (h or s): ").lower()
if h in s:
player.append(rc(cards))
else:
break
而不是
if h in s
比较
'h' in hs
我认为那是你错过的。