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 Python Basics (2015) Letter Game App Letter Game Introduction

plz help, when i enter my guessed word, it fills up the dashes and then it wont show that i won

import random import sys

make a list of words

words=[ 'apple', 'blueberry', 'orange', 'lemon', 'strawberry', 'pineapple', 'cocunut', ]

while True: start= input("Press Enter/return to Start, or enter q to quit: ") if start.lower() == "q": break #pick a random word secret_word = random.choice(words) bad_guesses = [] good_guesses = []

while len(bad_guesses) < 7 and len(good_guesses) != len(secret_word):
    #draw spaces
    for letters in secret_word:
        if letters in good_guesses:
            print(letters, end='')
        else:
            print('_', end='')
    print('')
    print("Strikes: {}/7".format(len(bad_guesses)))
    print('')        
#take gues
    guess = input("Guess a Letter: ").lower()

    if len(guess) > 1:
        print("you can only guess 1 letter at a time")
    elif guess in bad_guesses or guess in good_guesses:
        print("Yur Already Guessed That letter")
        continue
    elif not guess.isalpha():
        print("You Can only Guess Letters")
        continue
    if guess in secret_word:
        good_guesses.append(guess)
        if len(good_guesses) == len(list(secret_word)):
            print("You Win, U got it right, The word was {}".format(secret_word))
            break
    else:
        bad_guesses.append(guess)
else:
    print("your Word Was wrong u lose!!!!, the answer was {}".format(secret_word))        
#draw guessesd letters and strikes
#print out win/loss

2 Answers

fix the site sql injjection is vunerable when u add a comment lol, and dont forget to solve my code plz

plz