[Solved] Python: How find the index in list by its part?
[ad_1] I’d do it this way: result = [] reader = [‘sdsd-sdds’, ‘asaad’, ‘deded – wdswd’, ‘123’ ] str_1 = ‘deded -‘ for x in reader: if str_1 in x: result.append(reader[reader.index(x) + 1]) print(result) If you want to stop after finding the first one you should use a break after finding a value: result = … Read more