How do I use the re.sub python method to append +1 to a phone number?
When I use the following function it changes this string "802-867-5309" to this string "+1+15309". I'm trying to get this string "+1-802-867-5309". The examples in the docs replace show how to replace the entire string I don't want to replace the entire string just append a +1
import re
def transform_record(record):
new_record = re.sub("[0-9]+-","+1", record)
return new_record
print(transform_record("Some sample text 802-867-5309 some more sample text here"))