Free Photos
WordPress Themes

finding a char in a string

def isIn(char, aStr): ''' char: a single character aStr: an alphabetized string returns: True if char is in aStr; False otherwise ''' if aStr == '': return False if len(aStr) == 1: return aStr == char midpoint = len(aStr)/2 newChar = aStr[midpoint] if char == newChar: return True elif char < newChar: return isIn(char, aStr[: midpoint]) else: return isIn(char, aStr[midpoint:])

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.