Re: [Tutor] Split a string into characters

2005-08-22 Thread Alan G
>How do I split a string like "Hans" into a list of characters > ['H','a','n','s']? >>> list('fred') ['f', 'r', 'e', 'd'] >>> HTH, Alan G Author of the Learn to Program web tutor http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tu

Re: [Tutor] Split a string into characters

2005-08-22 Thread Hans Dushanthakumar
Bingo :) Thanks Rick -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rick Pasotto Sent: Tuesday, 23 August 2005 1:55 p.m. To: tutor@python.org Subject: Re: [Tutor] Split a string into characters On Tue, Aug 23, 2005 at 01:18:43PM +1200, Hans

Re: [Tutor] Split a string into characters

2005-08-22 Thread Rick Pasotto
On Tue, Aug 23, 2005 at 01:18:43PM +1200, Hans Dushanthakumar wrote: > Hi, >A quick one... >How do I split a string like "Hans" into a list of characters > ['H','a','n','s']? > Note that there are no spaces in the original string. >Str.split() without any arguments looks for whitespace

Re: [Tutor] Split a string into characters

2005-08-22 Thread luke
> How do I split a string like "Hans" into a list of characters > ['H','a','n','s']? [snip] well you could write your own function... def splititems(itemlist): templist = [] for item in itemlist: templist.append(item) return templist print splititems("Hello") or even def

[Tutor] Split a string into characters

2005-08-22 Thread Hans Dushanthakumar
Hi, A quick one... How do I split a string like "Hans" into a list of characters ['H','a','n','s']? Note that there are no spaces in the original string. Str.split() without any arguments looks for whitespace as splitting character. So, this doesn't serve the purpose. And str.split("") app