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 trialAhmet GULER
7,181 PointsPlease define the alignment rules of clearly.
i can pass the test with giving some spaces.. and fail it with lacking of spaces..
please compare the language with swift 2.0 to give examples of defining the alignment requirements .
Best Regards
def loopy(items):
# Code goes here
for abc in items:
if abc == "STOP":
break
else:
print (abc)
1 Answer
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsSo Python uses indentation for a block instead of curly brackets as Swift does.
Lines 4-7 are all inside of you're 'for' loop block, so they all need to be indented to the right. Then, the 'break' statement in the if block on line 5 needs to be intended again and so does 'print' inside the else block on line 7. Everywhere that Swift would have had a set of curly brackets, Python needs to indent.
def loopy(items):
# Code goes here
for abc in items:
if abc == "STOP":
break
else:
print(abc)