3-Digit Narcissistic Numbers Program - Python Just wanted to share my Narcissistic Numbers Program with y'all (not sure if it's good, but I gave it my best). Hope you like it!
This program prints out all the narcissistic numbers from the smallest number and biggest number's range. Ex. in the 1-100 range, only the narcissistic numbers will show on the console.
Some of you may be wondering, &quot;What the hell are narcissistic numbers??&quot; Once you go through a number of examples, I'm sure they won't be as bad as they sound (no pun intended). Narcissistic numbers are also known as Armstrong numbers, though I'm going to use the term 'narcissistic' rather than 'Armstrong' to avoid being inconsistent and flipping back and forth.
Overview: Narcissistic numbers are numbers that are equivalent to the sum of the cubes of their digits (3-digit numbers). This definition's verbose structure confused me, but after looking through a couple of examples, it made much more sense.

Procedure: (this is only applicable to 3-Digit Numbers)

Pick a number: 153

FYI: I broke the definition down into my own steps.

I split the number up into its individual digits; 1, 5 and 3
or you can just identify which digits the number (153 in this case) is composed of; 1, 5 and 3

Both ways bear the same result, but I tend to over-complicate things, so you can choose which way to use.

Now that all the digits are split up, we need to cube them all (separately) like this:
[1⋅1⋅1] + [5⋅5⋅5] + [3⋅3⋅3]; I included the square brackets for clarity's sake.

If you're not using brackets, then make sure you're following the BEDMAS rules.
If you simply calculate the following in a calculator: 1⋅1⋅1 + 5⋅5⋅5 + 3⋅3⋅3, then the result you will get is: 1025.

I believe I have provided a thorough enough over-view as to what narcissistic numbers are. Now, I hope the code will be easier for many people to understand.
The code is as follows:
import time
initial_time = time.time()

# initializing 's_number' (the smallest number) and 'l_num' (the largest number)
s_number = 100
l_number = 500

for number in range(s_number, l_number + 1):

    # order of the numbers
    order = len(str(number))

    # initializing sum
    sum = 0

    var = number
    while var &gt; 0:
        digit = var % 10
        sum += digit ** order
        var //= 10

    # setting restrictions for program
    if number == sum:
        print(number)

total_time = time.time() - initial_time
print('Time to complete task:',total_time)

If there's anything to change/add to make the program more efficient/better please don't hesitate to let me know. I would appreciate your insight on this project.
Nice solution, it's already efficient and easy to understand. Few general suggestions:

Avoid calling a variable sum: sum is a built-in function in Python, calling a variable sum prevents you from using such function.
time.perf_counter vs time.time: running your code I get 0.0 running time on Windows, which doesn't provide a useful information. Use time.perf_counter to get a better precision.
Make a function and return a result: if you wrap the code in a function it is easier to reuse and test. Additionally, instead of printing the numbers, add them to a list and return the final result. Printing only the result is typically faster than printing the numbers one by one.
Armstrong numbers: a narcissistic number is also called Armstrong number and here there is an efficient approach that I slightly modified to fit this question:
from itertools import combinations_with_replacement

def armstrong(n):
  numbers = []
  order = len(str(n))
  for k in range(1, order):
      a = [i ** k for i in range(10)]
      for b in combinations_with_replacement(range(10), k):
          x = sum(map(lambda y: a[y], b))
          if x &gt; 0 and tuple(int(d) for d in sorted(str(x))) == b:
              numbers.append(x)
  return sorted(numbers)



Extending the definition of Narcissistic number to:

An n-digit number that is the sum of the nth powers of its digits

The Narcissistic numbers till 1000000 are:
1, 2, 3, 4, 5, 6, 7, 8, 9, 153, 370, 371, 407, 1634, 8208, 9474, 54748, 92727, 93084, 548834

Runtime:
             n=1_000_000      n=10_000_000
Original:     3.374 s            40.26 s
Armstrong:    0.036 s            0.098 s

Full code:
import time
from itertools import combinations_with_replacement


def original(n):
    numbers = []
    for number in range(1, n):
        order = len(str(number))
        total_sum = 0
        var = number
        while var &gt; 0:
            digit = var % 10
            total_sum += digit ** order
            var //= 10
        if number == total_sum:
            numbers.append(number)
    return numbers


def armstrong(n):
    numbers = []
    order = len(str(n))
    for k in range(1, order):
        a = [i ** k for i in range(10)]
        for b in combinations_with_replacement(range(10), k):
            x = sum(map(lambda y: a[y], b))
            if x &gt; 0 and tuple(int(d) for d in sorted(str(x))) == b:
                numbers.append(x)
    return sorted(numbers)

# Correctness
assert original(1000) == armstrong(1000)

# Benchmark
n = 1_000_000

initial_time = time.perf_counter()
original(n)
total_time = time.perf_counter() - initial_time
print(f'Original: {round(total_time, 3)} s')

initial_time = time.perf_counter()
armstrong(n)
total_time = time.perf_counter() - initial_time
print(f'Armstrong: {round(total_time, 3)} s')