[pythonvis] Trace back error

  • From: "Al B" <ablazik@xxxxxxxxxxx>
  • To: <pythonvis@xxxxxxxxxxxxx>
  • Date: Thu, 22 May 2014 16:13:01 -0400

Hi Listers,
I created a separate program for the first sample loop program from Joseph and 
ran it. The answer displayed was 53. Not accepting this answer, I attempted to 
modify my program to print out each loops data fields: the number being 
examined and the counter value of even numbers. When that program was run, it 
produced a trace back error which said that "evencount is not defined.
Would someone tell me what I did wrong? Program code is below.

TIA, Al B

# sample loop program from Joseph

import random

random.seed()

l = []

for i in range(0, 100): l.append(random.randint(0, 100))

evenCount = 0

for numbers in l:

if numbers%2 == 0: evenCount+=1

print numbers%2 , evencount

print evenCount

?

# The following statement halts the program 

# so you can look at the screen

raw_input("press Enter to end program")

?

?

?

?

Other related posts: