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 Collections (2016, retired 2019) Sets Out Of This Word Game

My Modification for this game, I will happy if u can test the game and review the code :D

Hi :] I improved some features about the game i will happy if u can comment on the code, suggest more improvments.

this is the snapshot: https://w.trhou.se/8m5kcwsq41

which improvements i did? 1.A function which determine which player is the winner. 2.Getting players names 3.I tried to make an option to restart the game, I'm not sure why it isnt working, i did some exporements and if i dont use the else code block its restarting but then i dont have an option to check if it's not "Y". this is the snapshot with this improvment: https://w.trhou.se/ot8914imih

4.I added an option to see which words each player missed from the optional words. 5.i added a function named print_missing_words which responsible to print the missing words given the random word. 6.Users can't guess the same word if they already guessed it, they will get an massege

Chris Freeman Steven Parker Jeff Muday Dave StSomeWhere

I will appreciate if u can take a look at the code, especially in the number 3 improvment, i dont know where im wrong.

3 Answers

Steven Parker
Steven Parker
231,275 Points

For the restart question, you have this code:

        if user_decision.lower() == "Y":

Since nothing converted to lower case can match with capital "Y", you should compare to "y" (lower case) instead.

Also, there are a lot more words you can form with these base words — try using one of the many online anagram solvers to get your word lists. For example, just some of the other words you can make from "python" are: phyton, typhon, phony, pony, typo, hop, pot, to & toy.

Steven i added the words u suggested, thanks! the restart improvements still don't fully work. when i press y it works as intended, but when i press n instead of break out of the loop and print the goodbye massege it still restarting the game. i dont see any mistakes but it is the behavior THIS IS THE CURRENT SNAPSHOT: https://w.trhou.se/f96452mlue

i will appreciate your wisdom :]

Steven Parker

Steven Parker
Steven Parker
231,275 Points

There's a few ways to change that behavior:

  • add a "break" after the "restart_game()" on line 129
  • un-indent the "break" on line 132 so it happens on either branch of the "if"
  • remove the "while True" loop completely along with the break :point_left: recommended

Steven Parker The solution was so simple.., i used ur recommended option. I over-complicated it, btw before i tried it with the "while true", i did the same thing but somehow it didn't worked :0. the problem was with the equility check to "Y" instead of "y"?, i tested it and when i check the equility to "Y" instead of "y" it dosent work, and when i press y it just print the goodbye massege, Can u explain why?
Did u find the print_missing_words function good?

thanks

Steven Parker
Steven Parker
231,275 Points

As I said the first time, checking equality to "Y" instead of "y" can't work because the input has been converted using "lower()".

And good use of sets in "print_missing_words". :+1:

Steven Parker Hi :D ^^