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

I am stuck in this challenge(Dungeon Game: Line endings)

Can someone please help me out in this challenge

mapping.py
TILES = ('-', ' ', '-', ' ', '-', '||',
         '_', '|', '_', '|', '_', '|', '||',
         '&', ' ', '_', ' ', '||',
         ' ', ' ', ' ', '^', ' ', '||'
)
for title in TILES:
    if titlei == "||":
        end1 = "\n"
        print("\n")
    else:
        end1 = ""
        print(title, end=end1)
    print(title, end=end1)

1 Answer

Christian Mangeng
Christian Mangeng
15,970 Points

Hi Prateek,

here's how it could look like. I added some comments to show you what I changed in your code:

for title in TILES:
    if title == "||":  # removed the i in titlei (though it should be called tile, not title)
        # removed end1 here, as not needed
        print()  # print() already prints one newline at the end by default, so print("\n") would print two
    else:
        end1 = ""
        print(title, end=end1) 
    # removed this print command line, as not needed

Hope that helps