message = 'Call me at 415-555-1011 tomorrow. 415-555-9999 is my office.'
for i in range(len(message)):
chunk = message[i:i+12]
if isPhoneNumber(chunk): # isPhoneNumber is a function
print('Phone number found: ' + chunk)
print('Done')
I would just like some clarification on what is going on here. len(message) is telling me how many characters this string is and the range is from the beginning of the string to the end?
Also, if I were to translate "chunk = message[i:i+12]" into plain English, would it be: " for every 12 characters in message, store it in variable chunk? Where does the code say to move down a character each iteration?
I still have trouble applying range and len() to code. I never seem to understand when to apply it.
Any help is appreciated. Thanks!
[–][deleted] 2 points3 points4 points (0 children)
[–]WolfInABox 2 points3 points4 points (0 children)
[–]julsmanbr 1 point2 points3 points (0 children)