Python Forum

Full Version: returns index of list if contains a word
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

how can i return index from the list if it contains special character + values?

example:

line1: [word1], [word2], [$300]

line2: [$4000], [word2], [word3]

How to return index when it starts with "$" to get from first line "$300" and from second line "$4000"?

Found answer:
import re


re.findall(r'[$]\w+', text)