you are facing the error because you are using range function in wrong manner.
range(start, stop[, step]) -> range object
Here if step and start value is not provide then start value is consider as 0 by defualt and less than end value. also start is inclusive value and end is exclusive.
so in short range(start, end, step) -> start, start+step, start+step+step, ...., end-1`
in your code,
if num_1 > num_2:
for i in range(num_1,num_2+1):
# so on
here you are checking, if num_1>num_2, do for operation on range(num_1. num_2), so since step is not defined by you, it is taken as 1 by default
now the range(num_1, num_2) become [] as num_1 > num_2 and you cant reach num_2 by adding 1 to num_1 continousily. ie so list(range(num_1, num_2)) is [].
since it is empty for loop wont work and it exit the program. same happen (in opposite manner) when num_1<num_2.
to solve this you need to provide the correct value in range or change the if conditions.
so solution be like this
if num_1 < num_2:
for i in range(num_1,num_2+1):
print(i)
else:
for i in range(num_1,num_2,-1):
print(i)
num1 > num2then getrange(num1, num2)which is not iterating because no elements span fromnum1tonum2. Example, if5 > 4.. thenrange(5,4)doesnt give anything.