-2

I have made a guessing game program but every time I run it on VS code or Sublime it only displays the first output and hangs. If I use Python IDLE it runs my whole program. Here's the code below:

# This is a guess the number game.
import random

guessesTaken = 0

print('Hello! What is your name?')
myName = input()

number = random.randint(1, 20)
print('Well, ' + myName + ', I am thinking of a number between 1 and 20.')

while guessesTaken < 6:
    print('Take a guess.')
    guess = input()
    guess = int(guess)

    guessesTaken = guessesTaken + 1

    if guess < number:
        print('Your guess is too low.') #There are eight spaces in front of print

    if guess > number:   
        print('Your guess is too high.')

    if guess == number:
        break

if guess == number:
    guessTaken = str(guessesTaken)
    print('Good job, ' + myName + '! You guessed my number in ' + guessesTaken + ' guesses!')

if guess != number:
    number = str(number)
    print('Nope. The number I was thinking of was ' + number)
MattDMo
  • 100,794
  • 21
  • 241
  • 231
  • What happens if you have a file consisting only of `print("hi"); print(input())`? You may have better luck if you make your question a bit more narrow, focus on one IDE/editor, and give us some minimal steps to reproduce the problem you're encountering. – Greg Nisbet Jan 05 '17 at 03:59

1 Answers1

-1

I have the solution to your problem. If you have downloaded sublimeREPL. Go to tools > SublimeREPL > Python > Python - RUN current file

if not then copy this package control:

https://packagecontrol.io/installation

Go to View > show console > and copy the link above > click Enter and when it is done close sublime and open it again.

Then go to > Preferences > Package control > and type > sublimerepl

Once you have donwloaded you can follow the steps above.

hope it works.

  • As clearly stated on the [Package Control Installation page](https://packagecontrol.io/installation), `Warning: Please do not redistribute the install code via another website. It will change with every release. Instead, please link to this page.` Additionally, this post does not answer the question. – MattDMo Jan 05 '17 at 14:21
  • Sorry I did not realized it. Thanks. – Daniel Chamas Jan 05 '17 at 18:31