Mar-26-2026, 12:21 AM
I have a text string, which is extracted from a list: 'first_name\nlast_name\nemail_address'
I want to find the position of the '\n' character so I can slice the string and assign each section to its own variable: first_name, last_name, email_address.
I figured that if I could find the position of '\n' I could slice the appropriate section. EXCEPT... what should work:
pattern = r'\'
text.find(pattern) continually returns -1, meaning that it can't find the new line character, even though that sneaky puppy is hiding in plain sight.
What's the best/easiest way to separate these three fields into three separate variables?
Thanks,
Larry
I want to find the position of the '\n' character so I can slice the string and assign each section to its own variable: first_name, last_name, email_address.
I figured that if I could find the position of '\n' I could slice the appropriate section. EXCEPT... what should work:
pattern = r'\'
text.find(pattern) continually returns -1, meaning that it can't find the new line character, even though that sneaky puppy is hiding in plain sight.
What's the best/easiest way to separate these three fields into three separate variables?
Thanks,
Larry
