Note: I am not an official teacher or GSI for any of the courses listed on this site unless otherwise stated. Any problems and notes are created from my own observations and may not accurately reflect the course's content.

Recursion #2

The finding_nemo takes a non-negative single digit, nemo, and a non-negative integer, ocean. It returns the position of the first nemo in ocean, starting from the right side. The farthest right digit in ocean is position zero. Return False if nemo cannot be found in ocean. Refer to the doctests for examples how to use the finding_nemo function.

def finding_nemo(nemo, ocean):
	""" Find the position of the first digit equal to nemo in ocean, 
		   with the farthest right digit being zero. If not found, return False.

		   >>> finding_nemo(4, 12345)
		   1
		   >>> finding_nemo(3, 13375)
		   2
		   >>> finding_nemo(4, 123)
		   False
		   >>> finding_nemo(3, 3)
		   0
		   """
	def marvin(ocean, fish_tank):
		head, tail = ocean // 10, ocean % 10
		if _________________________________ :
			return False
		if _________________________________ :
			return _________________________________
		return _________________________________
	return _________________________________

Solution

Have a question? Found an error? Email me at imran.khaliq@berkeley.edu with the URL of the page and a short description.