Guessing Game

Configurare noua (How To)

Situatie

This script is an interactive guessing game, which will ask the user to guess a number between 1 and 99.

Backup

import random
n = random.randint(1, 99)
guess = int(raw_input("Enter an integer from 1 to 99: "))
while n != "guess":
    print
    if guess < n:
        print "guess is low"
        guess = int(raw_input("Enter an integer from 1 to 99: "))
    elif guess > n:
        print "guess is high"
        guess = int(raw_input("Enter an integer from 1 to 99: "))
    else:
        print "you guessed it!"
        break
    print

Solutie

Tip solutie

Permanent

Voteaza

(10 din 21 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?