Im trying to write a code for a colour picker, so a user can pick 4 different colours and then it would return them so i can use them in a different par tof the program, but its not working properly and i can work out why. any ideas?
def colourpicker():
print "pick four different colours from; red, green, blue, yellow, orange, pink, brown"
colourList = ["red", "green", "blue", "yellow", "orange", "pink", "brown"]
coloursPicked = []
while True:
colour1 = raw_input("pick first colour: ")
if colour1 in colourList:
break
colour1 = raw_input("not in list, pick agin: ")
coloursPicked.append(colour1)
return coloursPicked
while True:
colour2 = raw_input("pick second colour: ")
if colour2 in coloursPicked:
break
colour2 = raw_input("colour already picked, pick again: ")
if colour2 in colourList:
break
colour2 = raw_input("not in list, pick agin: ")
coloursPicked.append(colour2)
return coloursPicked
while True:
colour3 = raw_input("pick third colour: ")
if colour3 in coloursPicked:
break
colour3 = raw_input("colour already picked, pick again: ")
if colour3 in colourList:
break
colour3 = raw_input("not in list, pick agin: ")
coloursPicked.append(colour3)
return coloursPicked
while True:
colour4 = raw_input("pick fouth colour: ")
if colour4 in coloursPicked:
break
colour4 = raw_input("colour already picked, pick again: ")
if colour4 in colourList:
break
colour4 = raw_input("not in list, pick agin: ")
coloursPicked.append(colour4)
return coloursPicked
i think some of the loops might not be working how i want them too, but i cant seem to work it out.