Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Top Posters

Who's Online (1)

Powered by Vanilla. Made with Bootstrap.
Guessing game
  • Simple guessing game written in Python

    #!/usr/bin/python
    '''
    Python random number game. Generates a random number and the user must guess the number
    '''
    import sys, random
    rand = random.randrange(1, 1000)
    def main():
    number = rand
    guesses = 0
    while (1):

    guess = int(raw_input('Pick a number between 1 and 1000: '))
    if guess == number:
    print(\"Correct guess after %d guesses\" % guesses)
    sys.exit()
    elif guess < number:
    print(\"Too low, try again\n\")
    guesses += 1

    elif guess > number:
    print(\"Too high, try again\n\")
    guesses += 1


    main()
  • Sh3llc0d3
    Posts: 1,910
    Nice and simple, would keep people busy on a VERY bored day lol