document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. # Selecting Substrings : Writing a Python Procedure
  2.  
  3. # Let p and q each be strings containing two words separated by a space.
  4.  
  5. # Examples:
  6. #    "bell hooks"
  7. #    "grace hopper"
  8. #    "alonzo church"
  9.  
  10. # Write a procedure called myfirst_yoursecond(p,q) that returns True if the
  11. # first word in p equals the second word in q. Return False otherwise.
  12.  
  13. def myfirst_yoursecond(p,q):
  14.     first_word = p[0:p.find(" ")]
  15.     second_word = q[(q.find(" ")+1):]
  16.    
  17.     if first_word == second_word:
  18.         return True
  19.     else:
  20.         return False
  21.    
  22.  
  23. print myfirst_yoursecond("head boy", "rotten hell")
  24.  
  25. #print myfirst_yoursecond("bell hooks", "curer bell")
  26. #>>> True
');