I have a piece of code that looks a bit like this:
for peak in R_max_peaks, R_min_peaks:
rounded = '%s' % float('%.1g' % peak)
if rounded not in result_R:
attractors_R[i].append(rounded)
But I also have other arrays that only change 'R' for other letters, such as
for peak in N_max_peaks, N_min_peaks:
rounded = '%s' % float('%.1g' % peak)
if rounded not in result_N:
attractors_N[i].append(rounded)
Is there any pythonic way I could avoid writing this same piece of code multiple times, changing only the capital letter, for a set of capital letters? Something like ('R', 'N', 'H', 'P'), for example?