Python中的颜色序列游戏

时间:2016-07-14 10:00:07

标签: python

下面的代码用于python中的颜色序列猜测。

import random
import time

def colorgame():
    r='red'
    b='blue'
    g='green'
    y='yellow'
    v='violet'
    bl='black'
    o='orange'
    w='white'
    m='magenta'
    colors = [r, b, g, y, v, bl, o, w, m]
    sequence=[]
    win = True

    while win == True:


            else:
                win=False

在第一次迭代中,sequence = 'red'用户输入red并打印"Correct"。但是,当涉及到第二次迭代(比如说)sequence = ['red', 'green']并且用户输入'red' 'green'时它没有返回正确的。请帮助我纠正代码,以便将用户输入作为列表接受并与现有列表进行比较(sequence

1 个答案:

答案 0 :(得分:0)

在完成评论并清楚了解您的问题后,我得到了一些答案:

answer = input("Enter answer here:").split()

已编辑:感谢@mhawke