2 problems

symonlandor at gmail.com symonlandor at gmail.com
Sat Jul 8 00:51:04 EDT 2006


Mike Kent wrote:
> symonlandor at gmail.com wrote:
> > Hello,Im using Python 2.4.2 and I'm starting a few very basic
> > programs,but theres two problems I've not found the answers for.
> > My first problem is I need code that will count the number of letters
> > in a string and return that number to a variable.
>
> >>> s = "hello"
> >>> len(s)
> 5
>
> > My second problem stems from the first as I need a function that can
> > slice the string into letters and have those put in seperate
> > strings.Ive tried using the normal [:1],[:2],etc but I need a function
> > that can do that a variable amount of times due to the varying number
> > of letters in the input.
>
> >>> s = "hello"
> >>> list(s)
> ['h', 'e', 'l', 'l', 'o']
>
> >
> > This would be of great help,as python is new to me.
>
> Welcome aboard!

Thank you greatly,this is exactly what I needed,and this language is
alot more powerful than I thought!




More information about the Python-list mailing list