Hi I was wondering if it was possible to assign a value in the while comparison section of the code.
Here is an example of the code currently
startIndex = find(target, key, startIndex)
while( startIndex != -1):
matchesFound += 1
startIndex = find(target, key, startIndex + 1)
return matchesFound
What I want to do is move the startIndex = find(target, key, startIndex) into the while comparison expresion so it would look something like this
while( (startIndex = find(target, key, startIndex)) != -1):
matchesFound += 1
startIndex + 1
return matchesFound
if not, what would a better refactor be?
Thanks
edit I'm working through the MIT Open courseware 6.00 before I try out the famous 6.001 module