我正在尝试创建一个记忆游戏,其中用户选择他们希望播放的记忆游戏的长度,然后通过cimage弹出提供的许多选择的图片,然后让他们输入REPL。我目前正在收到AttributeError: 'list' object has no attribute 'draw'
形式的红色文字....不知道我哪里出错或如何修复它。任何帮助将不胜感激。感谢
from time import *
import random
from random import randrange
from cImage import *
default = FileImage("comp_def.gif")
j = FileImage("green_man.gif")
k = FileImage("yellow_man.gif")
i = FileImage("red_man.gif")
u = FileImage("blue_man.gif")
playerdef = FileImage("player_def.gif")
window = ImageWin("Simon Says", 640, 480)
compturn = [j,k,i,u]
rand = random.choice(compturn)
game = input('Welcome to Simon Says! Use the U I J & K keys to play. When you are ready to play press S followed by the enter key')
if game == 'S' or 's':
playerdef.draw(window)
play = int(input('What length of pattern would you like to atempt?'))
#generate random list
var = random.sample(compturn, play)
for i in var:
var.draw(window)
sleep(2)
pattern = input("Enter letters in order in all lower case keys")
if pattern == var:
print("You win!")
else:
print("Sorry, try again..")
else:
print("Command not recognized")