jeudi 14 juillet 2016

Issues with python

I'm trying to write a simple random number guessing program and it has weird issues. If I enter a number too high it will end the script and it's just glitchy.

# Guess my number 2

import random
random = random.randint(1,32)
attempts = 0


start = input("Welcome to guess my number, type 1 for a standard game or 2 for a custom > ")

if start == "1":
    guess = input("Ok i have a random number,  it is inbetween 1 and 32, try and guess it > ")

    while int(guess) > random:
        print("That number is too high")
        attempts = attempts + 1
        g = input("Try again > ")

    while int(guess) < random:
        print("That number is too low")
        attempts = attempts + 1
        g = input("Try again > ")

    if int(guess) == random:
        print("Well done, you win")

Aucun commentaire:

Enregistrer un commentaire