100""> 100"">
Ad

Code Will Ask To Input A Digit Greater Than 100 And If It Will Be Smaller Than 100 So A Loop Will Be Activated Else It Will Show "the Number Is > 100"

Please tell how can I correct this code

1

Hi, I am 12 years old and I am in 8th Class my teacher gave me this task to write a program which will ask to enter a number greater than 100 and then it will check whether it is greater than 100 or not , if not so it will apply a for loop and if it is greater than 100 so it will show that "the number is greater than 100"

Ad

Answer

This is what your code should look like:

a = int(input("Enter a value bigger than 100: "))

# loop ends if the number is bigger than 100 otherwise it will run forever
while a <= 100: 

    print("try again")
    # asks the use for input 
    a = int(input("Enter a value bigger than 100: "))

print("Congrats, you entered a value bigger than 100")
Ad
source: stackoverflow.com
Ad