0

this is my code currently:

previous = 0
count = 0
counts = []
item = str(data)

for x in range(len(item)):
    if dates[x][3] != previous[3] or dates[x][4] != previous[4]:
            if negative[x] != "No Negative":
                counts.append(count)
                count = 0
    count += 1
    previous = dates[x]


print(counts)

I keep getting an "'int' object is not subscriptable error. my values for dates and data are lists and I'm assuming the issue is that they aren't strings but nothing I do fixes the error.

thank you

Aaron
  • 10,133
  • 1
  • 24
  • 40
Reina297
  • 11
  • 2
  • 2
    It means that you are trying to do something like this: `10[0]`. – Shmack Jan 08 '23 at 00:30
  • 1
    Please always include the complete Traceback - copy and paste it then format it as code (select it and type `ctrl-k`). – wwii Jan 08 '23 at 00:42
  • 1
    [How to step through Python code to help debug issues?](https://stackoverflow.com/questions/4929251/how-to-step-through-python-code-to-help-debug-issues). If you are using an IDE **now** is a good time to learn its debugging features Printing *stuff* at strategic points in your program can help you trace what is or isn't happening. [What is a debugger and how can it help me diagnose problems?](https://stackoverflow.com/questions/25385173/what-is-a-debugger-and-how-can-it-help-me-diagnose-problems) – wwii Jan 08 '23 at 00:43
  • 1
    `previous = 0` - `previous` is an int on the first iteration. – wwii Jan 08 '23 at 00:46

1 Answers1

3

The problem is in previous[3].

previous is int, it's not subscriptable.

Alex Bochkarev
  • 2,851
  • 1
  • 18
  • 32