Re: [Tutor] How to handle conjunction operators

2011-11-28 Thread Steven D'Aprano
Timo wrote: if name[0] in ("m", "f", "b"): Or even shorter: if name[0] in "mfb": Shorter, but wrong. name = ['fb', 'ph', 'xy'] # oops, bad data if name[0] in 'mfb': ... Bad data should lead to an error as close as possible to the source of the bad data, and do the wrong thing for a w

Re: [Tutor] How to handle conjunction operators

2011-11-28 Thread Peter Otten
surya k wrote: > 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

Re: [Tutor] How to handle conjunction operators

2011-11-28 Thread Timo
Op 27-11-11 20:02, Hugo Arts schreef: On Sun, Nov 27, 2011 at 7: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:]

Re: [Tutor] How to handle conjunction operators

2011-11-27 Thread Alan Gauld
On 27/11/11 19:02, Hugo Arts wrote: if name[0] == "m" or name[0] == "f" or name[0] == "b": or, more idiomatically, you can use the in operator like this: if name[0] in ("m", "f", "b"): And you might want to force it to lower case too: if name[0].lower() in ("m", "f", "b"): OTOH you might w

Re: [Tutor] How to handle conjunction operators

2011-11-27 Thread bob gailer
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

Re: [Tutor] How to handle conjunction operators

2011-11-27 Thread bob gailer
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

Re: [Tutor] How to handle conjunction operators

2011-11-27 Thread Hugo Arts
On Sun, Nov 27, 2011 at 7: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.. I

[Tutor] How to handle conjunction operators

2011-11-27 Thread surya k
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