Hello,

list.remove will remove the first occurrence of the value from the list. So
the output is expected as far as Python is concerned.
May be you should think about using pop function.
Please take a look at the code below


>>> def RemoveComingDuplicates(a):
for i in range(len(a)-1):
 print i,i+1
if a[i+1] == a[i]:
a.pop(i+1)
 print a

>>> a = ['2','5','7','5','5']
>>> RemoveComingDuplicates(a)
0 1
['2', '5', '7', '5', '5']
1 2
['2', '5', '7', '5', '5']
2 3
['2', '5', '7', '5', '5']
3 4
['2', '5', '7', '5']
>>>

Hope this helps.

Thanks and Regards,
Sumod
On Thu, Nov 10, 2011 at 12:54 PM, lina <lina.lastn...@gmail.com> wrote:

> >>> for i in range(len(a)):
>        if i == 0:
>                b.append(a[i])
>        if a[i]!=b[-1]:
>                b.append(a[i])
>
> This one seems work, but looks clumsy,
>
> Thanks for any suggestions that helps to improve.
>
> Best regards,
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
http://spawgi.wordpress.com
We can do it and do it better.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to