def evenodd(li): i = 0 j = 0 while i < len(li): if not li[i] & 1: li[i],li[j] = li[j],li[i] j += 1 i += 1