I am pretty sure my code for ps3c is okay comparing it to others but when I run the test function I cannot get it to work. It says cannot iterate None, so I am stuck?!? here is my code def constrainedMatchPair(firstMatch,secondMatch,length): """Takes two tuples and length of first substring and returns tuple""" allAnswers = [] m = length for k in secondMatch: for n in firstMatch: if k == n + m + 1: allAnswers.append(n) print tuple(allAnswers)
Your problem is that your printing the solution, but not returning it, thus not giving the program anything to work with. (its like writing down an answer, but not handing it to the teacher. I know bad example but it just occurred to me) In the future, don't paste your code directly here (it gets difficult when you have several hundred lines) but use a site like dpaste.com
it says that can't iterate None - the only place you are iterating is in your for loops. the traceback should have pointed to a line number. from the the Python docs: None The sole value of types.NoneType. None is frequently used to represent the absence of a value, as when default arguments are not passed to a function. put a print statements in just after your docstring to print the arguments that are being passed to the function
Join our real-time social learning platform and learn together with your friends!