According to the definition, an Armstrong (Narcissistic) number is basically a number that is the sum of its own digits each raised to the power of the number of digits.
Therefore, change : sum += digit ** 3
to sum += digit ** len(str(num))

You can use a boolean variable, say flag which is initialised as False at the beginning. When you print an Armstrong number, set that flag to True. Now, in the end, if flag is still False, it indicates you havenâ€™t printed any Armstrong number. So we print -1 in that case.

lower = int(input())
upper = int(input())
flag = False
for num in range(lower, upper + 1):
...
...
while temp > 0:
...
...
if num == sum:
flag = True
...
...
if not flag:
print(-1)