Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

print all the narcissistic numbers found within a range

+1 vote
asked May 2, 2019 by abhilashi subash gogoi (130 points)

1 Answer

0 votes
answered May 5, 2019 by Sukanta Majhi

def print_narcissistic_nums(start, end):
    for i in range(start, end + 1):
       # Get the digits from the number in a list:
       digits = list(map(int, str(i)))
       total = 0
       length = len(digits)
       for d in digits:
          total += d ** length
       if total == i:
          print(i)
print_narcissistic_nums(1, 380)

I think it will help you...

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...