This is creating a single integer that’s the concatenation of all the numbers in CaseNumberList
, not a list of integers:
IntCaseNumberList = int("".join(str(i) for i in CaseNumberList))
So when you try to ue IntCaseNumberList[i]
, it doesn’t work because it’s a number, not a list.
To create a list of integers, you need to call int()
inside in a list comprehension:
IntCaseNumberList = [int(i) for i in CaseNumberList]
You could also just put integers directly into CaseNumberList
in the first place, then you wouldn’t need to make a new list. Change
CaseNumberList.append(CaseNumber)
to
CaseNumberList.append(int(CaseNumber))