Question: MODIFY THE TEMPLATE TO: Write code that returns true or #false whether the number 42 is in a two dimensional list #of integers (so each

MODIFY THE TEMPLATE TO: Write code that returns true or #false whether the number 42 is in a two dimensional list #of integers (so each element of the list is another list) #that the user supplies. import subprocess #from answer import * import sys def template(l1): numbersList = l1 return True #END OF YOUR CODE test1 = template([[1,3],[7,4,9,42,6],[5,11,-3]]) test2 = template([[1,3],[7,4,9,6],[5,11,-3]]) if test1 == True: print "you got it RIGHT!" else: print "for ([[1,3],[7,4,9,42,6],[5,11,-3]]) we expected True, but you got: " + str(test1) if test2 == False: print "you got it RIGHT!" else: print "for ([[1,3],[7,4,9,6],[5,11,-3]]) we expected False, but you got: " + str(test2) source = open(sys.argv[0],"r") lines = source.readlines() source.close() ctr = 1 failed = False while ctr < len(lines) and lines[ctr][:-1] != 'source = open(sys.argv[0],"r")': line = lines[ctr] if ('(".index(" in line or ".rindex(" in line' not in line) and (".index(" in line or ".rindex(" in line or ".remove(" in line or ".count(" in line or ".find(" in line or ".split(" in line or ".rsplit(" in line or ".rindex(" in line or ".join(" in line or "sorted(" in line or "min(" in line): print "ERROR: on line " +str(ctr) + ": "+ line + " you are using a forbidden function or method. You are only allowed to use len(...) and/or .append(...) for this assignment." failed = True ctr += 1 if not failed and test1 == True and test2 == False: print "Your code is CORRECT!"

else: print "Please check your code, at least one test case did not pass."

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!