[Tutor] split a 5 chars word into 4 and 1

Serdar Tumgoren zstumgoren at gmail.com
Tue Mar 9 16:34:45 CET 2010


> Hello,
>
> I'm trying to split 5 chars words (codes) into 2 variables. The first must
> contain the first 4 characters. The second variable will only contain the
> last character. I'm working in a loop pre-generated codes.
>
> Any magic command for this ? :-)
>
> Examples of codes :
> 3cmvA
> 3cmvB
> 3cmvC
> 3cmwA
> 1g18A
> 2g88A
> 1mo4A
>  2odwA
> 1u94A
> 1xmvA
> 1xp8A
> 2zr9A
>
> Thanks a lot !
>
> a+
>

Hmm...This sounds a bit like homework. Can you show us any code that you've
already tried? Meantime, you might want to explore Python's slice syntax:

http://docs.python.org/tutorial/introduction.html#strings
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100309/d81203b5/attachment.html>


More information about the Tutor mailing list