removing text string

Adam Pletcher adam.pletcher at volition-inc.com
Wed Sep 10 14:08:56 EDT 2008


You just want to drop the last two characters?  Slice it.

>>> s = "080829-7_A"[:-2]
>>> print s
080829-7

- Adam

> -----Original Message-----
> From: python-list-bounces+adam=volition-inc.com at python.org
> [mailto:python-list-bounces+adam=volition-inc.com at python.org] On
Behalf
> Of Ahmed, Shakir
> Sent: Wednesday, September 10, 2008 10:22 AM
> To: python-list at python.org
> Subject: removing text string
> 
> I need to remove text string from the list of the numbers mentioned
> below:
> 
> 080829-7_A
> 070529-5_c
> 080824-7_O
> 070405_6_p
> 
> The output will be : 080829-7
>                      070529-5
> 		         080824-7
>                      070405-6
> 
> Any idea is highly appreciated.
> 
> 
> 
> --
> http://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list