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) Dungeon Game Line endings

Nichole "Nikki" Carnesi
Nichole "Nikki" Carnesi
7,103 Points

I'm out of option...

I have gone through and read every person who struggled with this challenge. And it seems everyone figured it out after someone commented that they were missing an extra line. But flat out, I have zero clue what anyone is talking about. This is my code. I think it should work as is. I am frustrated. Please don't tell me that an extra line is needed, because I won't know what you are talking about. And the "preview" button doesn't do anything. How can I see what I am doing to know if I am on the right track or not? Trying workspace doesn't work either.

for tile in TILES:
    if tile == "||":
        line_end = "\n"
    else:
        line_end = ""
    print(tile, end=line_end)

2 Answers

james south
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,271 Points

don't you have an IDE? like canopy or spyder? you need to be able to run code like this. there is also pythontutor, a website. anyway, stepping through your code, we see that it looks at what the tile is and prints it, along with an end line character, but we are not supposed to print the double pipes. one way to solve this that i used is to introduce another variable and set it equal to the tile if it's a regular tile, and set it equal to the empty string if it's the double pipe, then in your print, you print this new variable, not the tile variable. so if tile = ||, tile2 = '' and end line = newline. else, tile2 = tile and end line = ''. then print tile2, not tile, along with end line.

Nichole "Nikki" Carnesi
Nichole "Nikki" Carnesi
7,103 Points

James, thank you for your patience. Last night I was moments away from tears, I was tired and felt defeated. I took your second comment advice and still couldn't figure it out. I'm thinking that I just don't understand this challenge at all. I am in the process of trying to download an IDE. Meanwhile, I just looked for another persons code and used that to pass this challenge because I couldn't handle it anymore. I need to move forward. Thanks again though.

james south
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,271 Points

your code prints the double pipes. the challenge says not to: "Print each item on the same line unless the item is a double pipe (||). In that case, instead of printing the item, print a new line (\n). " you just need to tweak it a little so that the pipes don't print.

Nichole "Nikki" Carnesi
Nichole "Nikki" Carnesi
7,103 Points

Honestly, I have no idea. I am assuming you mean using print() and I tried adding it right before "else:" with "title, end=line_end" or "\n" or nothing in at all. I even tried removing the "else:" statement altogether. Nothing. I tried swapping "\n" and "". I tried removing "tile" from print(). I'm not sure what else to do. I wish I could actually test this and see what it looks like but I have to guess what it's doing since the preview button doesn't work. It's frustrating doing all of this blindly when I am not 100% sure what I am doing yet. I tried looking at the for loop from the previous video with the "for cell in CELLS:" to see if there is any clue in that and nothing. Sorry, I'm just really overly frustrated with this.