Text comparison...

Hi, i would like to make a gradual transition from one piece of text to another but the problem is… i have no idea how to do it…

say first string = start and end string = goal, a transition string = trans…

so something like:

if trans != goal:
    for i in start:
        if start[i] != goal[i]:
            start[i] should change....

the changing of letters shouls go from a through to z, so if a character doesn’t fit the goal text and it equals to ‘a’ it should change to ‘b’, etc…

I hope i was clear, i try to be, if anyone has a solution…i’d be eternally grateful…

w.

I think I get what you’re talking about. I’ll try to post a solution as soon as I get one working.

Martin

Thanx, that would be a great help!!!

w.

there you go:


start = "allo"

end = "bwar"

trans = start

char = list("abcdefghijklmnopqrstuvwxyz")

print start

finish = 0
while not finish:
    StrList = [""]*len(start)
    for i in range(len(start)):
        if trans[i] != end[i]:
            li = char.index(trans[i]) + 1
            if li == len(char): li = 0
            StrList[i] = char[li]
        else:
            StrList[i] = trans[i]
    trans = ""
    for c in StrList: trans += c
    if trans == end: finish = 1
    print trans
    

Martin