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 trialEthan Koren
6,277 Pointsbreaks.py
can someone please help me out with this? i simply dont get it
def loopy(items):
# Code goes here
1 Answer
dojewqveaq
11,393 PointsHey Ethan,
the task is asking you to print every item in the items list, but skip the ones that start with the letter 'a'. So, you have to iterate through items, and if a certain condition is met, do something. Ok, so that's an if inside a for loop, something like this:
def loopy(items):
# Code goes here
for item in items: # this for loop will iterate through every 'item' in 'items'
if item[0] != "a": # if item DOESN'T start with the letter 'a' (!= means NOT, so if item's first letter isn't 'a', do
#something). It will print the current item.
print(item) # print 'item'
else:
continue # continue looping without doing anything if it starts with 'a'
Yushuai Cai
564 PointsYushuai Cai
564 PointsHi Eric,
I think Ethan was asking https://teamtreehouse.com/library/python-basics/shopping-list-app/break Challenge Task 2 of 2