Using Python’s list index() method on a list of tuples or objects?

How about this? >>> tuple_list = [(“pineapple”, 5), (“cherry”, 7), (“kumquat”, 3), (“plum”, 11)] >>> [x for x, y in enumerate(tuple_list) if y[1] == 7] [1] >>> [x for x, y in enumerate(tuple_list) if y[0] == ‘kumquat’] [2] As pointed out in the comments, this would get all matches. To just get the first one, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)