In: Computer Science
Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. If not, PLEASE let me know before you rate, I’ll help you fix whatever issues. Thanks
Note: Please maintain proper code spacing (indentation), just copy the code part and paste it in your compiler/IDE directly, no modifications required.
#code
import re
# pattern that matches a string with one or more digits followed by one space followed by one ore more
# letters followed by a space followed by one ore more letters
pattern = "[0-9]+\s[A-Za-z]+\s[A-Za-z]+"
# creating a string containing multiple street addresses for testing
string = "123 Main Street is just around that road opposite to 455 Fifth Avenue. 85 Daimler St. is also there"
# finding and printing all street addresses found in string using pattern
print(re.findall(pattern, string))
#output
['123 Main Street', '455 Fifth Avenue', '85 Daimler St']