help please

gargonx at gmail.com gargonx at gmail.com
Sat Feb 12 19:27:14 EST 2005


would anyone like to help to fugure out this problem i'm having here's
a portion of my code:

"""
I have three dictionaries along with this(you can probally spot what
they are), but just in case here are some testers:
"""
std = {
   "b":"bo"
    }

ext = {
    "aa":"i"
    }

punc = {
    ",":"!"
    }
"""
when i run this i get :

UnboundLocalError: local variable 't2' referenced before assignment

"""

OrigText="ba, baa bo."

t2=""

def Proc(text): # "text" is some random text or use OrigText
    for word in text:
        for letter in word:
            if letter in std.keys():
                letter=std[letter]
                t2=t2+letter  # the problem is referene to this
            elif letter in ext.keys():
                letter=ext[letter]
                t2=t2+letter
            elif letter in punc.keys():
                letter=punc[letter]
                t2=t2+letter

can anyone figure out why t2 is not being used properly?




More information about the Python-list mailing list