Write a python program to guess a number between 1 to 9. Note : user is prompted to enter a guess. If the user guesses wrong then the prompt appears again until the guess is correct, on successful guess, user will get a "well guessed!" message, and the program will exit.
Answers
Answered by
1
Answer:
n=("Guess any no")
if(n>9):
print(n)
else:
print(well guessed)
Answered by
7
The pyhton program to guess a number between 1 to 9 is as follows:
a= int(input("Enter a guess"))
while (a>9) or (a<1) :
a=int(input("Enter a guess"))
else:
print("Well guessed")
- This code prints "Well guessed" only if the input is between 1 and 9.
- If the number is greater than 9 or less than 1, the program prompts the user to enter the number again.
- To check whether the number is between 1 and 9, while loop is used.
Similar questions