python - UnboundLocalError: local variable 'slcount' referenced before assignment -


I am trying to iterate through the results obtained from the database, if the condition is being checked in condition and if If this is true then I want to raise the value for the row in the row

 : if line Leap unproved Type_ID == "Sick_Love" and row. Employee.leave_eligibility_id == 2: Global slough slcount + = 1 elif line. Save Type_ind == "CASUAL_LEAVE" and the row. Employee.leave_eligibility_id == 2: clcount + = 1 elif line.Slaced. Type_ind == "PRIVILEGED_LEAVE" and the row. Employee.leave_eligibility_id == 2: plcount + = 1   

but

  unboundLocalError: Local variable 'slcount' is referred before the assignment   

I have also tried "global", but it is showing error below. Name: The global name 'slcount' is not defined

"post-text" itemprop = "text ">

You did not assign a value for plcount befor using E. Slcount = clcount = plcount = 0: ...

for a row in the

  rows:   

/ p>

Python is a dynamically typed language

This means that you can do it in Python:

  & gt; Foo = 12 & gt; Foo = 'aaa'   

are you looking? I can specify any type of value for a variable. Instead, in a fixed typed language:

  & gt; int foo; & Gt; Foo = 12; & Gt; Foo = 'AAA'; // you can not do it!   

However, this does not mean that you can do this in Python:

  & gt; Foo = foo + 1 # You have not specified a value for Foo!    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -