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 trialTafadzwa Masocha
1,240 Pointshi guys
def loopy(items): # Code goes here items=['abz', 'xyz'] if index[0] in items=='a' continue else" print(item)
def loopy(items):
# Code goes here
items=['abz', 'xyz']
if index[0] in items=='a'
continue
else"
print(item)
2 Answers
Rich Zimmerman
24,063 PointsThe "items" list is passed into your function when it is called. So while you don't have an actual value for "items", you know it's going to be a list of values. So you want to run your function through it accordingly. like this:
for item in items:
# item is the value of the item in the array for each index, so item[0] is index 0 of the word that's being passed as 'item'
if item[0] == 'a':
continue
else:
print(item)
FHATUWANI Dondry MUVHANGO
17,796 Pointsyou need to first loop through each item in "items", its better if you use the "for loop" to do that and also you need to target the first item and test if it is equal to the string 'a', you use the "if" statement for that and if your first item in your list is not equal to the string 'a', then use the "else" statement to print that item
see the code from Rich Zimmerman for step by step clearity