How to check if two words that start with specific letter in strings from a list in Python

1 Answer

0 votes
import re

strings = ["abstract about", "c# c++", "absolute-ability ", "java php"]

for s in strings:
    two_words = re.match("(a\w+)\W(a\w+)", s)

    if two_words:
        print(two_words.groups())


'''
run:

('abstract', 'about')
('absolute', 'ability')

'''

 



answered Aug 31, 2018 by avibootz
...