-1

I'm trying to have a piece of code function like a list of answers for a certain phrase and spit it out, here is what I've done so far.

nolan = "Red"
haden = "blue"
raj = "green"
hossein = "orange"
francisco = "indigo"
christian = "black"
chris = "brown"
lee = "lime green"
vince = "violet"
person = input("ask me who is what color :  ")
print(person + " is " + )
#not sure at all where to go from here

#i'm going for it to be able to take a name and spit out what color it is 

1 Answers1

0

Make it a dictionary. You will want to check whether they entered a name you don't know, but here's the principle:

colors = {
    "nolan": "red",
    "haden": "blue",
    "raj": "green",
    "hossein": "orange",
    "francisco": "indigo",
    "christian": "black",
    "chris": "brown",
    "lee": "lime green",
    "vince": "violet"
}
person = input("ask me who is what color :  ")
print(person + " is " colors[person] )
Tim Roberts
  • 48,973
  • 4
  • 21
  • 30