Click here to Skip to main content
15,867,594 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Error is "Int object is not subscriptable.
input should should assign in single variable like
a = 12 24
and after we need to find lcm and gcd.

What I have tried:

a = int(input())
for i in range(a):
    b = input().split()
    c = (a[0])
    d = (a[1])
    n1, n2 = c, d
    while c > 0:
        r = c%d 
        d = c
        c = r
gcd = d
lcm = (n1*n2)//gcd
print(gcd)
print(lcm)
Posted
Updated 22-Jan-22 9:17am
Comments
0x01AA 22-Jan-22 13:30pm    
You split the input into b therefore you should get the values from b?

c = (b[0])
d = (b[1])

1 solution

Quote:
input should should assign in single variable like
a = 12 24

Unfortunately, it is variable b.
Try
Python
b = input().split()
c = (b[0])
d = (b[1])
 
Share this answer
 
Comments
shri harshan 23-Jan-22 1:05am    
I am still getting error
Richard MacCutchan 23-Jan-22 3:25am    
See my answer to your repost of this question.
Patrice T 23-Jan-22 4:31am    
what error ? with what code ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900