I've got a series of headlines. I want to capture only the first word in the text.
for line in messy_info:
match = re.search(r"^[a-z]{7}",line)
if match:
first_word.append(line[:10])
first_word
This brings back the first 10 characters, I do not know how to bring back only the first word in this instance.
MY next challenge is to use this first word and print the headline and then underneath the first word.
for line in messy_info:
match = re.search(r"^[a-z]", line)
if match:
first_word = line [:100]
print (first_word)
splitline = re.split(r"\s[a-z]+\s",word)
print ("First Word: ",splitline[0])
print()
else:
print("--- not a match ---")
print()