Home > Blockchain >  TypeError: 'type' object is not subscriptable at a for loop
TypeError: 'type' object is not subscriptable at a for loop

Time:03-06

import numpy

lim = int(input("Write the limit of a function: "))

licz = list(input("Write the numerator: ").split(" "))

mian = list(input('Write the denominator: ').split(" "))

print(licz)

x = len(licz)

y = len(mian)

if len(licz) > len(mian):
    n = int(len(mian))
else:
    n = int(len(licz))

wyniklicz = 0
wynikmian = 0
for i in range[0, n]:
    for f in range[0, len(licz)]:
        wyniklicz =  lim**(len(licz)-f 1)*licz[f-1]
    for e in range[0, len(mian)]:
        wynikmian =  lim**(len(mian)-e 1)*mian[e-1]
    if wyniklicz == 0 and wynikmian == 0:
        licz = numpy.polydiv(licz, [1, -lim])
        mian = numpy.polydiv(mian, [1, -lim])
    if wyniklicz == 0 and wynikmian != 0:
        answer = 0
        break
    if wyniklicz != 0 and wynikmian == 0:
        answer = "infinity"
        break

print(answer)

This is my code, I get this error at line 22:

for i in range[0, n]:

I've looked through some other posts with a similar error and I just can't see what I'm doing wrong. Can anyone try to help me?

CodePudding user response:

You need open and closed parenthesis for range

for i in range(0, n):
  • Related