+ 2
Can anybody fix my code?
Hi i'm making a code about Armstrong number, so if the user enter two number example: 15 I want my program to check if the user is an Armstrong number but why my code prduce an error can anybody fix it and explain me? https://code.sololearn.com/cimTRaakP4Ux/?ref=app
4 Answers
+ 1
#i dont know the wanted code but i corrected it
num = input()
while num != 0:
if (int(num[0]) ** int(num[1]) + (int(num[1]) ** int(num[1])) == int(num)):
print("yes your nunber is an armstrong number")
else:
print("sorry your number is not an armstrong number")
break
+ 2
The error is quite clear. 'int' type is not subscriptable. Means you can't access it by index.
Suppose user enters 15, then what you're trying to use is, 15[0] which doesn't make sense as it's not a list or tuple. What you can do is, store the numbers takes by the user in a list.
num = [int(input()),int(input())] and as you might be knowing the drill of SoloLearn, enter every input in a new line.
+ 2
Thank you guys!
0
Hello seniors
I'm just here seeking for your help, i just want to make my fourth project but i really don't know how to do it.
The program ask for the input and check if the number is palindrome number or not.
Please help š