+ 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

9th Apr 2019, 7:59 AM
Gavrie Sashenka
Gavrie Sashenka - avatar
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
9th Apr 2019, 8:18 AM
Sousou
Sousou - avatar
+ 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.
9th Apr 2019, 8:08 AM
ŠØŠ°Ń‰Šø Š Š°Š½Š¶Š°Š½
ŠØŠ°Ń‰Šø Š Š°Š½Š¶Š°Š½ - avatar
+ 2
Thank you guys!
9th Apr 2019, 9:44 AM
Gavrie Sashenka
Gavrie Sashenka - avatar
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 šŸ™
16th Jan 2023, 8:41 AM
Adamu Mustapha
Adamu Mustapha - avatar