Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics (2015) Number Game App Number Game Introduction

Jackson Stitzel
Jackson Stitzel
551 Points

Why can't I play my Number game?

here is my code why won't it work:

import random

# generate a random number 1-10
secret_num = random.randint(1, 10)

while True:
    # get a number guess from the player
    guess = int(input("Guess a number between 1 and 10: "))
    #pcompare guess to secret number
    if guess == secret_num:
        print("you got it! My number was {}".format(secret_num))
        break
    else:
        print("Thats not it")
    #print hit/miss
nakalkucing
nakalkucing
12,964 Points

I'd love to help. But I can't read your code. Could you please put it into proper syntax? If you don't know how to take a look at the Markdown Cheatsheet. :)

nakalkucing
nakalkucing
12,964 Points

Thanks! :) What error is Workspaces giving you? Specifically, which line does it say your problem is on?

2 Answers

Steven Parker
Steven Parker
220,477 Points

This program seems to work just fine!

Maybe it's how you are starting it up? What do you do to cause the program to begin running?

Jackson Stitzel
Jackson Stitzel
551 Points

I re rote all of my code and it started to work I think I had an error before