On Thu, Nov 10, 2011 at 8:48 PM, Steven D'Aprano <[email protected]> wrote:
> lina wrote:
>>
>> Hi,
>>
>> How to remove the coming duplication,
>>
>> Here I wrote one (not working):
>>
>>
>>>>> a=['2', '5', '7', '5', '5']
>
> [...]
>>
>> I wish to get a is [2,5,7,5]
>>
>> just remove the coming duplication, not unique the list.
>
> a = [2, 5, 7, 5, 5]
> b = a[0:1] # slice of the first item only
> for x in a[1:]: # slice of the second item to the end
> if x != b[-1]:
> b.append(x)
for index, b in enumerate([b_list]):
print(b)
how can I avoid the output not as:
['53', '76', '57']
but as
53
76
57
Thanks
>
>
> gives b = [2, 5, 7, 5] as requested.
>
>
>
> --
> Steven
> _______________________________________________
> Tutor maillist - [email protected]
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor