Function in Soundex module doesn’t work

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at. The query string (? and beyond) may be truncated.>

<In what way does your code behave incorrectly? Include ALL error messages.>
This is one of the functions in a soundex module I’m running to deal with SPSS data. It used to work, years ago, but now it generates “Error Computing Case” for each case. Anyone have an idea why this might be happening??
<What do you expect to happen instead?>

```python

def spssoundex(newvariablename,computingvariable):
import spss
varnames =
varcount = spss.GetVariableCount()
for i in xrange(varcount):
varnames.append(spss.GetVariableName(i))
varindex = varnames.index(computingvariable)
cursor = spss.Cursor(accessType = ‘w’)
cursor.SetVarNameAndType([newvariablename],[4])
cursor.CommitDictionary()
for i in range(cursor.GetCaseCount()):
indcursor = cursor.fetchone()
try:
cursor.SetValueChar(newvariablename,get_soundex(indcursor[varindex]))
cursor.CommitCase()
except:
print “Error Computing Case”
try:
print casecursor[varnames.index(“CASE”)]
except:
print “CASE variable not in file”
cursor.close

<do not remove the three backticks above>

def get_soundex(name):
“”"name -> Soundex code, following Knuth Vol 3 Ed 2 pg 394.

The number of digits generated can be modified by setting the
module-level variable, NDIGITS (default 3).
"""

if not name:
    raise ValueError("soundex requires non-empty name argument")
coded = name.translate(_tran)
out = [name[0].upper()]
lastrealcode = coded[0]
ignore_same = 1
for thiscode in coded[1:]:
    if thiscode == "B":
        ignore_same = 0
        continue
    if thiscode == "I":
        continue
    if ignore_same and lastrealcode == thiscode:
        continue
    out.append(thiscode)
    lastrealcode = thiscode
    ignore_same = 1
    if NDIGITS and len(out) > NDIGITS:
        break
if len(out) < NDIGITS + 1:
    out.append("0" * (NDIGITS + 1 - len(out)))
return "".join(out)

This function may be the root of the above function’s issues…