o=t=[];a=input()for i in a: if i%2:t=[i]+t else:o+=t+[i];t=[]print(o+t)
[123,123,345,0,1,9]
[345, 123, 123, 0, 9, 1]
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!