Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Out of this word error.

I made my code in out of this word, but it won't work. Maybe I missed a part of the video? I thought I followed along pretty well, but I'm not sure

import random

WORDS = (
    "treehouse",
    "python",
    "learner",
)

def prompt_for_words(challenge):
    guesses = set()


def promt_for_words(challenge):
    guesses = set()
    print("What words can you find in the word '{}'".format(challenge))
    print("(Enter Q to Quit)");
    while True:
        guess = input("{} words >   ".format(len(guesses)))
        if guess.upper == "Q":
            break
        guesses.add(guess.ower())
    return guesses

def output_results(results):
    for word in results:
        print("* " + word)


challenge_word = random.choice(WORDS)

player1_words = prompt_for_words(challenge_word)
player2_words = prompt_for_words(challenge_word)

print("Player 1 Results:")
player1_unique = playe1_words - player2_words
print("{} guesses, {} unique".formate(len(player1_words), len(player1_unique)))
output_results(player1_unique)
print("-" * 10)
print("Player 2 Results:")
player2_unique = playe2_words - player1_words
print("{} guesses, {} unique".formate(len(player2_words), len(player2_unique)))
output_results(player2_unique)

print("Shared guesses:")
shared_words = player1_words & player2_words
output_results(shared_words)
Steven Parker
Steven Parker
229,732 Points

To preserve your indentation (critical with Python!) use "Markdown" formatting. Instructions can be found in the Markdown Cheatsheet pop-up below the "Add an Answer" area. :arrow_heading_down:

Or for more detailed instructions, you can watch this video on code formatting.

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,423 Points

There are some typos:

  • promt_for_words instead of prompt_for_words
  • guess.ower() instead of guess.lower()
  • guess.upper missing ()
  • .formate() instead of format()
  • playe2_words instead of player2_words