'Write a program that generates an integer between 1 and 100 and prompts the user to guess it [closed]

After entering each number by the user, the program should report whether the hidden number is greater or less. The program should count the number of attempts and after how the number is guessed - display the corresponding message.

import random

number = int (random.randint (1,100) )
attempts = 0
guess = input ('Guess the value from 1 to 100.')
while guess != number:
    if guess == number:
        print ('Congratulations, you guessed it right!')
    elif guess < number:
        print ('Your guess is less than the number.')
    elif guess > number:
        print ('Your guess is bigger than the number.')
    attempts += 1
    guess = input ('Guess the value from 1 to 100.')

print ('The amount of attempts:', attempts)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source