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 trialAsif Choudhury
2,086 PointsMy Python IDLE is giving right answer, but I am failing the challenge
When I test my code in my computer's IDLE, it gives the result, but for reason unknown to me, I am failing the test.
Thanks a bunch for your time!
TILES = ('-', ' ', '-', ' ', '-', '||',
'_', '|', '_', '|', '_', '|', '||',
'&', ' ', '_', ' ', '||',
' ', ' ', ' ', '^', ' ', '||'
)
for i in TILES:
if (i=='||'):
print('\n')
else:
print(i,end='')
2 Answers
Steven Parker
231,275 PointsRemember how the print() function works.
Without using the end option, the print() function will add a new line to your output by default. So to print just a new line, you can write print('')
. Printing a newline character explicitly will cause two new lines to be output.
Asif Choudhury
2,086 PointsThanks Steven Parker for your explanation; it certainly helped.
Luke Flanagan
5,752 PointsLuke Flanagan
5,752 PointsThis is a Lifesaver, the wording on the question seems very confusing because it mentions the "\n" which you in fact should not be using
Steven Parker
231,275 PointsSteven Parker
231,275 PointsI agree that is a bit confusing, but another way you could output a single newline is like this:
print('\n', end='')