Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You need open and closed parenthesis for range

for i in range(0, n):
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading