n = input("Enter a number: ") x = len(n) z = 0 for i in range(x): y = int(n[i])**x z += y if z == int(n): print(f'{n} is an Armstrong number') else: print(f'{n}is not an Armstrong number')
Hi, could you please elaborate your query. Those 3 lines are normal text files that were written by Python code. If you are asking about IDE, you can use any. I am using Pycharm IDE.
If you want to work on pc or laptop, you can choose vs code, pycharm, any kind of text editor or in any interpreter. Or if you want to work and run code on Android device, you can choose terminux, app like Android studio, pydroid3 (offline) and etc.
Sir i have written this code: a=input("Enter your number: ") p=0 for i in a: p=p+int(i)**3 if int(a)==p: print("The number entered is armstrong") else: print("The number entered is not armstrong") it is also showing the same output, so can i consider is right? or do i have to use your method??
Hi, I'm just having an overview of your code. It does seem correct. And yes, you can use your method as long as your code returns you the correct result. In addition to that it is good practice to follow best practices. I have followed the function based approach. However, the code can be written without function as well. Keep Learning.
Hi, by looking at code, it seems correct. Are you getting some errors? And yes, a program can be written in many ways, provided it gives the right output and follows good practices. Your approach is another way of doing it. Happy learning.