Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (18.4k points)

I am trying to get a specific index from the multiple lists.

When I print the lists this is what I get as my output:

['Sep', '8', '2007', 'Honda', 'Civic', 'EX', 'sedan', 'CLEAN', 'TITLE', '$1,999', '(Flushing)']

['Sep', '8', 'CHEVROLET', 'SILVERADO', '2500', 'NO', 'RESERVE', '33K', 'MILES', '$1,400']

['Sep', '8', '2007', 'Chrysler', 'Town', 'and', 'Country', '$1,000', '(McGinley', 'Square)']

['Sep', '8', '2003', 'Hyundai', 'Elantra', '$1,600']

['Sep', '8', 'We', 'buy', 'cars', 'for', 'cash', '$2,000', '(Upper', 'East', 'Side)']

How do I achieve it?

1 Answer

0 votes
by (36.8k points)

Use regular expressions:

id=[i for i, item in enumerate(arr) if re.search('^\$', item)]

Here the arr represent any list.

Improve your knowledge in data science from scratch using Data science online courses

Browse Categories

...