Q:

Range between numbers and if else statement

I'm slowly learning Python on my own so here is a problem I've been running into.
Trying to step through each number up to the last number and depending on the range it steps into then a calculation will be made.
NUM = []
for b in range(1,8760):
  if 3000 < b < 7000:
    NUM=500
  else:
    NUM=300
writer.writerow([NUM])

TypeError: 'int' object not iterable

I also tried this below and it runs but only prints out one number for the whole list instead of choosing between the two number options...
NUM = []
for b in range(1,8760):
  NUM = numpy.where((b > 3000) & (b < 7000), 500, 300)
writer.writerow([NUM])

A:

Did you mean this instead?
NUM = []
for b in range(1,8760):
  if 3000 < b < 7000:
    NUM.append(500)
  else:
    NUM.append(300)
writer.writerow(NUM)

