How to Get String Passed Into Function in Python


In this example we will show how to get the string passed into the function when using regular expressions in Python.

Source Code

import re

str1 = 'I love Python'

r = re.search('o', str1)

print(r.string)

Output:

I love Python
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments