3 ms·
My first thought is below. However I'm not sure if this is a good problem to ask unless you want them to iterate on the solution and you mention you want to do
by jtchang 8y ago
My first thought is below. However I'm not sure if this is a good problem to ask unless you want them to iterate on the solution and you mention you want to do in a functional way.
def groupByOddThenEvens(someList):
odds = []
evens = []
for x in someList:
print x
if x % 2 == 0:
# Even
evens.append(x)
else:
odds.append(x)
odds.extend(evens)
return odds