Hi everyone, I am currently making a game in python. The objective of the game is to guess out the number within 6 guesses. I want to make a window that also involves graphics inside. I want to let the program have a box where you can enter in the value and another box that shows the results.I am kind of stuck on how to combine graphics with my code together. I know there are a lot flaws in my code. I would really appreciat it if you guys could help me, thanks!

Inline Code Example Here

    if guesses < 5:

from graphics import *

Text=Point(30,50,"Hello and welcome to the guessing game. The goal of this game is to guess a number between 1 to 100. you have six chances. There will be hints. Good luck.")
Text(Point(250,100 ), "Take a guess:D")
input = Entry(Point(300,100),50)
import random
number = random.randint(1, 100)
guesses = 0
guess = input()
guess = int(guess)
while guess!= number:
    if guesses < 5:
        if (guess< number):
            print('Your guess is too low')
            guesses= guesses + 1
            guess= input
        if guess > number:
            print('Your guess is too high.')
            guesses= guesses + 1
            guess= input
    if guesses==6:
        if guess != number:
            print (' You are '+ abs(number-guess) + 'numbers away, one last guess!')
if guess == number:
    guesses = str(guesses)
    print('Good job! You guessed my number in ' + guesses + ' guesses!')
    number = str(number)
    print('Nope. The number I was thinking of was ' + number)

I would not use input as a variable name, especially as you also try to use also the function input, which is hidden due to this.

There also has to be a button that is pressed, or some other event trigger, to tell the progam when to get the value from the input GUI.

This article has been dead for over six months. Start a new discussion instead.