I need to find the smallest value in a list. The list has sublists which contains tuples. I need to find the smallest value in all of those tuples, but it can only include the first 3 values. I managed to achieve with the following code, but I want it to look cleaner.
lst = [[(1, 2, 3, 50)], [(0.2, 0.4, 2, 0.1)], [(0.6, 0.8, 1.2, 0.05)]]
def FitScoreSearch3(fitscores):
fitscores2 = []
for x in fitscores:
for y in x:
for z in y[:3]:
fitscores2.append(z)
return min(fitscores2)
The output is 0.2 as it should be. The output can't be 0.05.
min([value for sublist in lst for value in sublist[0][:3]])