我正在编写一个基于手风琴风格的纸牌的 python 程序。我已经编写了上面的代码,并且在过去的几个小时里一直在玩它,但我似乎无法使循环正确运行。无论出于何种原因,它要么只运行一次循环,不再要求输入,要么运行一次,询问输入,无论我输入什么,它都会崩溃。有什么想法我在这里做错了吗?
这是我的代码:
import random
print("Command Options:")
print("1C - Play card C onto pile 1 position back, ignored if invalid")
print("3C - Play card C onto pile 3 positions back, ignored if invalid")
print("C - Count of undealt cards")
print("D - Deal next card")
print("H - Print this help screen")
print("R - Resign this game (quit early)")
print("X - Exit Program")
cards=['AC','2C','3C','4C','5C','6C','7C','8C','9C','TC','JC','QC','KC','AD','2D','3D','4D','5D','6D','7D','8D','9D','TD','JD','QD','KD','AH','2H','3H','4H','5H','6H','7H','8H','9H','TH','JH','QH','KH','AS','2S','3S','4S','5S','6S','7S','8S','9S','TS','JS','QS','KS']
random.shuffle(cards,random.random)
playable=[]
done=False
while not done:
move=input("Enter move: ")
move_upper=move.upper()
if move_upper == 'D':
playable.append(cards.pop())
print(playable)
if move_upper == 'X' or 'R':
done=True
if move_upper == 'H':
print("Command Options:")
print("1C - Play card C onto pile 1 position back, ignored if invalid")
print("3C - Play card C onto pile 3 positions back, ignored if invalid")
print("C - Count of undealt cards")
print("D - Deal next card")
print("H - Print this help screen")
print("R - Resign this game (quit early)")
print("X - Exit Program")
if move_upper == 'C':
k=0
for item in cards:
k+=1
print(K,'cards left')