How to find words in a string that start with specific character in Python

1 Answer

0 votes
s = "java python c c++ php c# rust go pascal"

words = [word for word in s.split() if word[0] == "p"]

print(words)




'''
run:

['python', 'php', 'pascal']

'''

 



answered Nov 26, 2022 by avibootz
...