10 Dec 2020

Posted on:

27 Oct 2020

0

# New Course! The Python Programmer Bootcamp with Giles McMullen-Klein

Please let me know what is wrong with the below code. This is 1st quest of practical challenge. It's working fine if I enter a number between 1-100 in the first go. However, if I put the number out of this range, it asks to enter a valid number again but doesn't go outside the while loop   num_1 = int(input("Enter first number :")) num_2 = int(input("Enter second number :")) while num_1 < 0 or num_2 < 0 or num_1 > 100 or num_2 > 100 or num_1 == num_2:     print("Please enter a valid number")     num1 = int(input("Enter first number :"))       num2 = int(input("Enter second number :"))   if num_1 < num_2:     for i in range(num_1,num_2+1):         print (i, end=' ')     else:     for i in range(num_2,num_1+1):         print (i, end= ' ')     Result : Enter first number :345 Enter second number :45 Please enter a valid number Enter first number :34 Enter second number :23 Please enter a valid number