Okay, so the answer is probably obvious, but I don’t know the correct way to get the program to respond differently depending on what the user types.
octopusList = {"first": ["red", "white"],
"second": ["green", "blue", "red"],
"third": ["green", "blue", "red"]}
squidList = ["first", "second", "third"]
squid = random.choice(squidList)
octopus = random.choice(octopusList[squid])
The lists and the squid and octopus generate a random phrase
resp = raw_input("Please Type Something")
while resp !=1:
if resp == octopusList:
print squid + " " +octopus
break
elif resp == "Something":
print "Elephants are pachyderms"
break
else:
print "That's another text to think about."
break
print "One More Comment"
This is supposed to print squid + ” ” +octopus if the user inputs anything on the octopusList. Or, if the user types “Something”, it should return the phrase “Elephants are pachyderms”. If the user types anything esle, it should return the phrase “That’s another text to think about.” Lastly it should print “One More Comment”. What it actually does is skip strait to else no matter what the user types.
It goes strait to Else so there’s something I’m not getting about the if and the elif… thanks for any light you can shine on this.
Comparing a string to a dictionary does not do anything useful (it will always be false, IIRC) — did you maybe want ‘
if resp in octopusList‘? I’m not sure why the second conditional never hits, perhaps you typed “something” instead of “Something”?