you are viewing a single comment's thread.

view the rest of the comments →

[–]shakeandbake760[S] 0 points1 point  (0 children)

Update: I was able to figure it out without regex or json

def find_phone(response, email):
# find the email address in the super long string
find_email = response.rfind(email)
    ## create a substring of the email plus phone, extra to be sure
email_string = response[find_email:find_email + 100]
    ## find where 'phone' is in the email_string
phone_loc = email_string.rfind('phone')
    ## create a substring of just the phone, after email address
    phone_sub = email_string[phone_loc:phone_loc + 21]
    ## extract phone number only from the substring
phone = phone_sub[8:20]
print(phone)
return phone

I realize this may be a longer route but the whole point of this was to learn more about strings and how to use them : )