[Tutor] populating an array or using a dictionary

Bryan Fodness bryan.fodness at gmail.com
Sun Oct 21 20:21:01 CEST 2007


Here is my code.

dic2 = {}
for line in file('21Ex6MV_tmr.dat'):
    d, fs1, fs2, fs3, fs4, fs5, fs6, fs7, fs8, fs9, fs10,
    fs11, fs12, fs13, fs14, fs15, fs16, fs17, fs18, fs19,
    fs20, fs21, fs22, fs23, fs24, fs25, fs26, fs27, fs28,
    fs29, fs30, fs31, fs32, fs33, fs34, fs35, fs36, fs37,
    fs38, fs39, fs40 = line.split()
    dic2[d] = (float(d), float(fs1), float(fs2), float(fs3),
                  float(fs4), float(fs5), float(fs6), float(fs7),
                  float(fs8), float(fs9),  float(fs10), float(fs11),
                  float(fs12), float(fs13), float(fs14), float(fs15),
                  float(fs16), float(fs17), float(fs18), float(fs19),
                  float(fs20), float(fs21), float(fs22), float(fs23),
                  float(fs24), float(fs25), float(fs26), float(fs27),
                  float(fs28), float(fs29), float(fs30), float(fs31),
                  float(fs32), float(fs33), float(fs34), float(fs35),
                  float(fs36), float(fs37), float(fs38), float(fs39),
                  float(fs40))
    print dic2[d]

and, here is my error

Check\eDoseCheck.py", line 44, in <module>
    d, fs1, fs2, fs3, fs4, fs5, fs6, fs7, fs8, fs9, fs10,
NameError: name 'd' is not defined
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20071021/26b8363d/attachment.htm 


More information about the Tutor mailing list