I apologize from the outset for the eyesore this probably is. I’m not even 100% sure how to properly phrase what I’m trying to do. I’m very new to Python and coding in general.
I am essentially trying to say:
if "str" in "raw_input string":
print "b"
elif "raw_input string" contains "x" or "y" or "z":
print "a"
else:
print "c"
I can get it to work if I type the following:
if "str" in "raw_input string":
print "b"
elif "x" in "raw_input string":
print "a"
elif "y" in "raw_input string":
print "a"
elif "z" in "raw_input string":
print "a"
else:
print "c"
I figure there has to be a more efficient way to do this though. Again, I’m sorry if this is a stupid question. I’m very new to this.
Yep, you have to be very clear with Python and any programming language. If you think about, even the English sentence “I if me and my friend have clothes, or a rain coat, or an umbrella, then it’s raining” is wrong. You aren’t being clear in that sentence about who has the rain coat or umbrella. We kind of assume “my friend” does, but Python assumes nothing. You must write: “If my friend has clothes, or I have a rain coat, or my friend has an umbrella and I have an umbrella, then it’s raining.”