samedi 23 janvier 2016

Python guessing game keeps return same output

I am trying to create a python function that makes you guess a number 0 - 100. Every time I run the code, it always prints lower, even when I put the lowest number possible(0). How can I prevent this and have my code run correctly.

Here is my code:

from random import *
z = False

def whle(i):
    x = raw_input("Guess My Number 1 - 100")
    if x < i:
        print "Higher"
        q = False
        z = True
    elif x > i:
        print "Lower"
        q = False
        z = True
    elif x == i:
        print "Correct!"
        q = True
        z = False
    else:
        print "Guess My Number You Goofy Goose!"
        q = False
        z = True
def number():
    y = randrange(0,101)
    q = False
    while q == False:
       whle(y)
while z == False:
    number()




Aucun commentaire:

Enregistrer un commentaire