12,396,961 members (38,311 online)
Rate this:
See more:
I have to just use this list I cant create any list
For example:
```a=[5,9,1,1,10,21,34,21,1,3,4,39,40,50,60,70]
```
Output of this list has to be:
`[70, 60, 50, 40, 10, 39, 34, 4, 3, 1, 21, 21, 1, 1, 9, 5]`

my code:
```a=[5,9,1,1,10,21,34,21,1,3,4,39,40,50,60,70,3,1]

v=len(a)-1
i=0

while(i<len(a)):>

d =a[i]%2
if (d==1):
if(v<i):>
print(a)
break
l=a[i]

a[i]=a[v]
a[v]=l

v-=1

i+=1
```

if I add any odd number end of the list something went wrong
if ı have this list:
`a=[5,9,1,1,10,21,34,21,1,3,4,39,40,50,60,70,3,1]`
I got :
```[1, 3, 70, 60, 10, 50, 34, 40, 39, 4, 3, 1, 21, 21, 1, 1, 9, 5]
```
What do I need to do?
Posted 7-May-13 11:32am
Updated 7-May-13 11:37am
v2
richcb 7-May-13 17:36pm

Why did you repost this?

Top Experts
Last 24hrsThis month
 OriginalGriff 155 Karthik Bangalore 150 Richard MacCutchan 135 BillWoodruff 95 ppolymorphe 85
 OriginalGriff 6,138 Karthik Bangalore 2,497 ppolymorphe 2,445 F-ES Sitecore 1,877 Richard MacCutchan 1,812