[Tutor] avoid split function
kumar s
ps_python at yahoo.com
Fri Aug 13 01:25:06 CEST 2004
Dear group,
I am a newbie to Python. I am grinding my abilities
in list datatypes and fuctions.
I am trying to avoid .split() function to process a
string.
My programs follows:
m = []
y = []
a = "This is a test"
for i in range(0,len(a)):
if a[i] == " ":
print y
elif a[i] != " ":
y.append(a[i])
m.append(y[0:])
I wanted to push "This" in to m as m = ['This']
I know i can do this using:
c = a.split()
I just wanted to avoid using split and make it work.
The output I always get is y =
['T','h','i','s','i','s','a','t','e','s','t']
I created m because I wanted to push each element of
y(y = ['T','h','i','s']) to m to make it ['This'].
Can any one help me please suggest some tricks of how
I could do that.
Thank you.
PS
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail
More information about the Tutor
mailing list