Python Forum
returns index of list if contains a word
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
returns index of list if contains a word
#1
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)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Thumbs Down I hate "List index out of range" Melen 20 3,154 May-14-2023, 06:43 AM
Last Post: deanhystad
  function returns dataframe as list harum 2 1,336 Aug-13-2022, 08:27 PM
Last Post: rob101
  IndexError: list index out of range dolac 4 1,843 Jul-25-2022, 03:42 PM
Last Post: deanhystad
  For Word, Count in List (Counts.Items()) new_coder_231013 6 2,497 Jul-21-2022, 02:51 PM
Last Post: new_coder_231013
  find some word in text list file and a bit change to them RolanRoll 3 1,482 Jun-27-2022, 01:36 AM
Last Post: RolanRoll
  IndexError: list index out of range Anldra12 2 1,408 May-03-2022, 01:39 PM
Last Post: Anldra12
  IndexError: list index out of range rf_kartal 6 2,759 Sep-07-2021, 02:36 PM
Last Post: Larz60+
  Python Error List Index Out of Range abhi1vaishnav 3 2,233 Sep-03-2021, 08:40 PM
Last Post: abhi1vaishnav
Question Problem: Check if a list contains a word and then continue with the next word Mangono 2 2,455 Aug-12-2021, 04:25 PM
Last Post: palladium
  IndexError: list index out of range Laplace12 1 2,186 Jun-22-2021, 10:47 AM
Last Post: Yoriz

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020