Hi Santosh, On Jul 17, 2012, at 10:09 PM, Santosh Kumar wrote:
> Here is my script: > > name = raw_input("What's your name? ") > > if name == "Santosh": > print "Hey!! I have the same name." > elif name == "John Cleese" or "Michael Palin": > print "I have no preference about your name. Really!!" > else: > print "You have a nice name." > > > The if part works well. The elif part works well too. The problem is > even if you enter strings other than "Santosh", "John Cleese" and > "Michael Palin" you still get the print from elif part, not from else > part. you just have to be careful with the multiple boolean line in the elif. You can use either elif name == ("John Cleese" or "Michael Palin"): or elif name == "John Cleese" or name == "Michael Palin": With your elif line, it is asking "does name == John Cleese" or "Michael Palin", and so if the name is not John Cleese, then I believe it prints "Michael Palin" while reporting True, so satisfying the elif clause. Cheers, Andre _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor