| Store | Cart

newbie question: getting rid of space in string :(

From: Joseph Youssef <lead...@hotmail.com>
Fri, 12 Jul 2002 01:52:42 -0400
Hello, I'm new to python and I'm writing a very small script which takes each letter of a string and adds text to it (I know this is not a good explanation but you'll understand below :) )

anyway, this is my current code:

def textColor(string, color1, color2):
    color = color1
    for a in string:
        print "<" +color+ "><b>" +a+ "</b></" +color+ ">",
        if color == color1:
            color = color2
        else:
            color = color1


so when I run let's say textColor("testing","black","red")
it returns:
<black><b>t</b></black> <red><b>e</b></red> <black><b>s</b></black> <red><b>t</b></red> <black><b>i</b></black> <red><b>n</b></red> <black><b>g</b></black>

now this works just fine exept that space in between each block of text, I can't get it to stick together, now I know this is a very easy question but I need some quick help

thanks 







-- 
Too often we lose sight of life's simple pleasures. Remember when someone annoys you it takes 42 muscles in your face to frown, BUT, it only takes 4 muscles to extend your arm and bitch-slap that mot...@#?!&! upside the head! 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20020712/73245205/attachment.htm>

Recent Messages in this Thread
Joseph Youssef Jul 12, 2002 05:52 am
Mark McEahern Jul 12, 2002 04:14 pm
Gerhard Haering Jul 12, 2002 04:17 pm
Martin Franklin Jul 12, 2002 04:59 pm
Alex Martelli Jul 12, 2002 05:29 pm
Alex Martelli Jul 12, 2002 05:30 pm
Martin Franklin Jul 12, 2002 06:49 pm
Messages in this thread