Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #56487
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2013-10-09 07:20 -0700 |
| Message-ID | <9610dace-0175-424a-b226-c401ce0f98b2@googlegroups.com> (permalink) |
| Subject | öpcaö variable refrenced before assignment |
| From | markotaht@gmail.com |
fail4 = "palgad.txt"
f4 = open(fail4, "r")
def koguarv_ridu failis(f):
for i, l in enumerate(f):
pass
return i+1
def palgad(f4):
palgad = 0
while True:
f4r = f4.readline()
if f4r == "":
break
palgad += int(f4r[f4r.find(";")+1:])
return palgad
def kuu_keskmine(palgad, f):
return palgad/koguarv_ridu_failis(f)
print(kuu_keskmine(palgad(f4), f4))
Why does it give me local variable "i" referenced before assignment in koguarv_ridu_failis(f) on the return i+1 line
But if i do directly koguarv_ridu_failis(f4) then i get correct antswer.
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
öpcaö variable refrenced before assignment markotaht@gmail.com - 2013-10-09 07:20 -0700
Re: öpcaö variable refrenced before assignment Chris Angelico <rosuav@gmail.com> - 2013-10-10 01:41 +1100
Re: öpcaö variable refrenced before assignment Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-10-09 17:52 +0300
Re: öpcaö variable refrenced before assignment markotaht@gmail.com - 2013-10-09 08:15 -0700
Re: öpcaö variable refrenced before assignment Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-09 16:37 +0100
csiph-web