Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Find index value in List
#2
>>> [item.index('cat') for item in test if 'cat' in item]
[1]
>>> [item.index('758') for item in test if '758' in item]
[0]
Reply


Messages In This Thread
Find index value in List - by Martin2998 - May-12-2020, 11:45 AM
RE: Find index value in List - by anbu23 - May-12-2020, 12:47 PM
RE: Find index value in List - by DeaD_EyE - May-12-2020, 12:55 PM
RE: Find index value in List - by deanhystad - May-12-2020, 02:17 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  IndexError: list index out of range Laplace12 1 103 Jun-22-2021, 10:47 AM
Last Post: Yoriz
  Find Common Elements in 2 list quest 4 467 Apr-14-2021, 03:57 PM
Last Post: quest
  IndexError: list index out of range brunolelli 11 925 Mar-25-2021, 11:36 PM
Last Post: brunolelli
  Changing Index of 2 List in python giddyhead 0 319 Mar-05-2021, 05:45 PM
Last Post: giddyhead
  IndexError: list index out of range ramu4651 2 543 Jan-24-2021, 01:45 PM
Last Post: buran
  List of error codes to find (and count) in all files in a directory tester_V 8 764 Dec-11-2020, 07:07 PM
Last Post: tester_V
  Find _ in a list 1234 15 1,162 Dec-01-2020, 07:53 PM
Last Post: bowlofred
Question Matching variable to a list index Gilush 17 1,038 Nov-30-2020, 01:06 AM
Last Post: Larz60+
  How to get index of minimum element between 3 & 8 in list Mekala 2 719 Nov-10-2020, 12:56 PM
Last Post: DeaD_EyE
  List index out of range error while accessing 2 lists in python K11 2 591 Sep-29-2020, 05:24 AM
Last Post: K11

Forum Jump:

User Panel Messages

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