AttributeError: 'builtin_function_or_method' object has no attribute 'split' (3)

1.1k views Asked by At

My code takes two inputs in one string inside the for loop. And I want to split that input to fill two variables. Here's my code:

P = int(input()) #Principal amt
T = int(input()) #Total tenure

N1 = int(input()) #Number of slabs of interest rates by bank A
sumA = 0
for i in range(N1):
    numberOfYears, monthlyInterestRate = [float(i) for i in input.split()]
    EMI = P * monthlyInterestRate / ( 1 - 1 / (1 + monthlyInterestRate)^(numberOfYears * 12))
    sumA = sumA + EMI

N2 = int(input())
sumB = 0
for i in range(N2):
    numberOfYears, monthlyInterestRate = [float(i) for i in input.split()]
    EMI = P * monthlyInterestRate / ( 1 - 1 / (1 + monthlyInterestRate)^(numberOfYears * 12))
    sumB = sumB + EMI
    
if sumA < sumB:
    print("Bank A")
else:
    print("Bank B")

Here's the error:

Traceback (most recent call last):
  File "/home/jdoodle.py", line 70, in <module>
    numberOfYears, monthlyInterestRate = [float(i) for i in input.split()]
AttributeError: 'builtin_function_or_method' object has no attribute 'split'

Input-

10000
20
3
5 9.5
10 9.6
5 8.5
3
10 6.9
5 8.5
5 7.9

Output-

Bank B
1

There are 1 answers

0
juhat On

You're missing parenthesis on input-method on this lines:

numberOfYears, monthlyInterestRate = [float(i) for i in input.split()]

Should be:

numberOfYears, monthlyInterestRate = [float(i) for i in input().split()]