First, you need brackets in some of your print
calls and you want input
rather than raw_input
, if you're using Python 3.
colors = ['R','Y','G','B','P','O']
print("player 1 Create a 4 color code using", colors)
print("player 2 look away!!")
p1code = input(">>> ")
if p1code == len(colors):
print("i got the code now!")
Otherwise, with Python 2.x, you don't need brackets, and it will probably help you avoid bugs if you're consistent (currently on your first print
line you also print the brackets ('player 1 Create a 4 color code using', ['R', 'Y', 'G', 'B', 'P', 'O'])
:
colors = ['R','Y','G','B','P','O']
print "player 1 Create a 4 color code using", colors
print "player 2 look away!!"
p1code = raw_input(">>> ")
if p1code == len(colors):
print "i got the code now!"
Secondly: You have stored the four colours in p1code
. When I run the above code:
player 1 Create a 4 color code using ['R', 'Y', 'G', 'B', 'P', 'O']
player 2 look away!!
RBGY #what I entered
In [9]: p1code
Out[9]: 'RBGY'
Thus you can see the string 'RBGY'
is stored in the variable p1code
.