Python Python Collections (2016, retired 2019) Dungeon Game Line endings

victor escarcega
victor escarcega
5,439 Points

close but not quite

my else statement is wrong but im drawing a blank here

mapping.py
TILES = ('-', ' ', '-', ' ', '-', '||',
         '_', '|', '_', '|', '_', '|', '||',
         '&', ' ', '_', ' ', '||',
         ' ', ' ', ' ', '^', ' ', '||'
)
for item in TILES:
    if item != '||':
        print (item)
    else:
        TILES= '\n'.join(TILES)

2 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 57,143 Points

Every print statement has an implied \n appended. So the challenge is actually asking is to print any non-|| item without a \n (this can be done with the end argument), and to print a new line if the item is ||. For the second condition, both print() and print('\n') will work.

Post back if you have more questions. Good luck!!

victor escarcega
victor escarcega
5,439 Points

This one works on my idle, but its not accepted for the challenge

for item in TILES:
    if item != '||':
        print (item, end = ' ')
    else:
        print(end = '\n')
victor escarcega
victor escarcega
5,439 Points

i had an extra space on my end statement. thats why it wasnt working but i got it figured out. Thank you!

victor escarcega
victor escarcega
5,439 Points
for item in TILES:
    if item != '||':
        print (item, end = ' ')
    else:
        print(end = '\n')

this one works on my idle, what do you think? Chris Freeman