def WhosonFirst(inputText, num, num2): x=inputText count=num count2=num2 x.strip("'.?!") if "who" in x.lower() or "whos" in x.lower(): if not "second" in x.lower() and not "third" in x.lower() and count<1: print "\nAbbott: That's it \n" count=count+1 return True, count, count2 elif not "second" in x.lower() and not "third" in x.lower() is True and count == 1: print "\nAbbott: That's the man's name\n" count=count+1 return True, count, count2 elif "second" in x.lower(): print "\nAbbott: No, what plays second base! \n" return True elif "third" in x.lower(): print "\nAbbott: Who is on first, I don't know's on third\n" return True, count, count2 else: print "\nAbbott: Exactly!\n" count=0 return True, count, count2 elif "what" in x.lower() or "whats" in x.lower(): if "what" in x.lower() and not "ask*" in x.lower() and count2<1: print "\nAbbott: What's the guy's name on second base.\n" count2=count2+1 return True, count, count2 elif "what" in x.lower() and not "askin*" in x.lower() and count2>1: print "Abbott: No. Who is on first, what plays second base\n " count2=count2+1 return True, count, count2 elif "ask*" in x.lower(): print "Abbott: I'm not asking you, I'm telling you\n" return True, count, count2 elif "second" in x.lower(): print "\nAbbott: Exactly!\n" return True, count, count2 else: print "\nAbbott: What is on second! \n" count=0 return True, count, count2 elif "why" in x.lower() and "ask*" in x.lower(): print "I'm not askin' you I'm tellin' you\n" return True, count, count2 elif "manager" in x.lower(): print "Yes, I'm the manager \n" return True, count, count2 elif "third" in x.lower(): print "\nAbbott: I don't know \n" return True, count, count2 elif "dont" in x.lower(): print "\nAbbott: Yes, I don't know's on third\n" return True, count, count2 elif "left" in x.lower(): print "\nAbbott: why\n" return True, count, count2 elif "because" in x.lower(): print "\nAbbott: Oh, he's center field\n" return True, count, count2 elif "pitcher" in x.lower(): print "tomorrow" return True, count, count2 elif "damn" in x.lower() or "damn" in x.lower(): print "\nAbbott: That's the shortstop's name!" return False, count, count2 else: print "\nAbbott: I'm tellin' you, Who is on first, What is on second, and I don't know is on third!\n" return True, count, count2 #------------Applicaition ----------------------------------------------------------- print "\nAbbott: Strange as it may seem, they give ball players nowadays very peculiar names... \n" print "Costello: Funny names?\n" print "Abbott: Nicknames, nicknames. Now, on the St. Louis team we have Who's on first, What's on second, I Don't Know is on third \n" start=True count=0 count2=0 while start: ask=raw_input("\nCostello: ") start,count,count2=WhosonFirst(ask,count,count2)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question