I want to know if I can use a loop in python to make it into single block of code that would fetch me best_result1_conf, best_result2_conf and best_result3_conf.
if best_score1 == '1.0':
best_result1_conf='High'
elif best_score1 > '0.85' and best_score1 < '1.0':
best_result1_conf='Medium'
else: best_result1_conf='Low'
if best_score2 == '1.0':
best_result2_conf='High'
elif best_score2 > '0.85' and best_score2 < '1.0':
best_result2_conf='Medium'
else: best_result2_conf='Low'
if best_score3 == '1.0':
best_result3_conf='High'
elif best_score3 > '0.85' and best_score3 < '1.0':
best_result3_conf='Medium'
else: best_result3_conf='Low'
scoreand returns aresult, that would reduce duplication. Also, store both in lists, rather than separate variables, it's much more scalable:results = [s_to_r(score) for score in scores]listto store your multiple variables.