On 11/27/2011 1:52 PM, surya k wrote:
Hi,

Could you please tell me why this isn't working and how can I make it possible...

Consider this code..
    name = raw_input("Enter your first name: ")
    if name[0] == ("m" or "f" or "b") :
       rhyme = name[1:]

What I want here is.. If the name starts with 'm' or 'f' or 'b', The first letter should be removed.
But this isn't happening here.
Hugh answered your question.

I add - let's analyze name[0] == ("m" or "f" or "b")

"m" or "f" or "b" gets evaluated first. The result is "m" (the first non-false value)

then name[0] == "m" gets evaluated, which may be true or false.


the shortest way is name[0] in "mfb"

--
Bob Gailer
919-636-4239
Chapel Hill NC

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to