-1
5048,3293,5242,3290,5244,3411,5050,3414

In this example 5048-5242-5244-5050 are from the same "family" same for 3293-3290-3411-3414 basically it's every other term . the end result i want and expect is the highest of the first "family" next to the highest of the second family and the lowet next to the lowest having the following end result.

['5242', '3414', '5048', '3290']

It can be easily done using 2 lists each having a +2 index one starting at 0 the other at 1 etc.. but what is an actually efficient pythonic way to do it.

user9266899
  • 35
  • 1
  • 5

1 Answers1

0

I would do it this way:

numbers = [5048,3293,5242,3290,5244,3411,5050,3414]

f3 = [n for n in numbers if str(n)[0] == '3']
f5 = [n for n in numbers if str(n)[0] == '5']

newList = [max(f5), max(f3), min(f5), min(f3)]
wohe1
  • 755
  • 7
  • 26