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 Challenge Solution

Joseph Godin
Joseph Godin
3,185 Points

This one is too tough honestly

I got as far as the while statement and used an if statement to create the loop but couldn't rmbr how to tie in the list into it. I ended up just following along and doing the exact code the teacher has. The code still doesn't even work correctly. I wish there were more practice coding things like this... I want to get better but throwing so many different parts into one challenge really makes it difficult.

4 Answers

Joseph Godin
Joseph Godin
3,185 Points

Okay I watched some Corey Schafer youtube videos and it helped clear up some concepts. I am still getting tripped up on the goalkeeper aspect though and i think it has something to do with me doing the code differently than the example.

proceed=input("Would you like to add a player to the roster? Yes/No  ")
while proceed.lower() == "yes":
    if proceed.lower() == "yes":
        name=input("Type the name of the player.  ")
        players.append(name)
        proceed=input("Would you like to add a player to the roster? Yes/No  ")
    if proceed.lower() == "no":
        print("\nThere are {} players on the team.".format(len(players)))

player_num=1
for player in players:
    print("Player {}: {}".format(player_num, player))
    player_num+=1

goalkeeper=input("Please select the goal keeper by selecting the player number. (1-{})".format(player_num))
goalkeeper=(int(player))```

any advice on how to get the goalkeeper integer to work on player so i can wrap this project up?

Instead of goalkeeper=(int(player)), you could get the player with the integer value of goalkeeper by using players[int(goalkeeper)].

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,252 Points

Just keep practicing until it sticks. It's okay that you don't get everything right away even in these practice sessions. Remember these practice workshops are designed to help you test many solutions to a single problem using the knowledge you've learned from previous courses so there's plenty of content for you to go on.

Try going through the practice again. And if you're following along take it step by step so you can get a handle on what each part of the code is doing. Code can look scary but if you try to remember concepts rather than memorising code that's a better way to look at it I think.

Post back the code you're trying if you still get stuck. Use the markdown cheatsheet on your page if you want to know how to format code in the forums. :)

Szymon Dabrowski
Szymon Dabrowski
2,207 Points

Don't give up. You are certainly not alone. I am in the same position as you are at the moment but eventually it will stick and we can then move onto something new and repeat the same steps haha

Joseph Godin
Joseph Godin
3,185 Points

Thanks. I think I will continue on and retry that practice again later in the week to continue trying to memorize and retain these concepts. Thanks for the encouragement.