All Courses

# Write a program to guess a number between 1 to 9 using elif.

##### By Pp5344229@gmail.com, 3 months ago

Write a program to guess a number between 1 to 9 using elif.

Python
If-elif-else
If else

Hint:

num = int(input("enter the number-->"))

if num == 1:

print(" ")

elif num == 2:

print(" ")

you have to guess the number using if elif else

##### Goutamp777

```number = input("Enter a number between 1 and 9: ")

if number == "1":
print("The number is 1.")
elif number == "2":
print("The number is 2.")
elif number == "3":
print("The number is 3.")
elif number == "4":
print("The number is 4.")
elif number == "5":
print("The number is 5.")
elif number == "6":
print("The number is 6.")
elif number == "7":
print("The number is 7.")
elif number == "8":
print("The number is 8.")
elif number == "9":
print("The number is 9.")
else:
print("The number is not between 1 and 9.")
```

This program will prompt the user to enter a number between 1 and 9, and then it will use a series of `elif` statements to check if the number is one of the numbers between 1 and 9. If the number is one of the numbers between 1 and 9, the program will print the number; otherwise, it will print a message saying that the number is not between 1 and 9.

#### Live Masterclass on : "How Machine Get Trained in Machine Learning?" Mar 30th (7:00 PM) 516 Registered
More webinars

#### Related Discussions

Running random forest algorithm with one variable

View More