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 trialSidharth Kaushik
Courses Plus Student 1,329 PointsOut Of This Word Error
import random
WORDS = ("treehouse", "python", "learner")
def prompt_for_words(challenge): guesses = set() print("What words can you find in this word '{}'".format(challenge)) print("Enter Q to Quit") While True: guess = input("{} words > ".format(len(guesses))) if guess.upper() == 'Q': break guesses.add(guess.lower()) 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 = player1_words - player2_words print("{} guesses, {} unique".format(len(player1_words),len(player2_words))) output_results(player1_unique) print("-" * 10) player2_unique = player2_words - player1_words print("{} guesses, {} unique".format(len(player2_words),len(player1_words))) output_results(player2_unique) print("-" * 10) print("Shared guesses:") shared_words = player1_words & player2_words output_results(shared_words)
This is my Code and i am getting an syntax error don't know why !!!!
treehouse:~/workspace$ python out_of_this_word.py
File "out_of_this_word.py", line 12
While true:
^
SyntaxError: invalid syntax
1 Answer
Balazs Peak
46,160 PointsYou are using "While" instead of "while". Keywords are case sensitive in any programming languages that I'm aware of. They are not case sensitive in SQL though, but that's a query language, not a programming language. :)
You can format you code snippets in a way that they would be more readable. This way people can help you better in the Treehouse community. Check this out: https://teamtreehouse.com/community/cheatsheet