I don't understand this exercise. I did what I could. Help please!!
Maybe the indentation is wrong, I don't know
def loopy(items): for item in items: if item.index(0) == "a": continue else: print(item)
Your code is actually very close to correct. The issue is that the
index method does not function in the way you might expect, it is actually used to find the index of a character, not to get something from an index.
Meaning that it expects to be passed something like a letter and will then tell you what index that letter is at.
So to check if
a was at index 0 using the
index method you would have to reverse the current logic of your code like this:
item.index("a") == 0
index method is not really well suited for this task to begin with, because it will throw an exception (basically an error) if it does not find the character you specify.
The ideal way to check the first letter in this task is to use bracket notation. With bracket notation you can just type the name of a string or list followed by a pair of brackets with an index. Like this:
And that will return the letter at that index.
If you use that in your code like this:
def loopy(items): for item in items: if item == "a": continue else: print(item)
Then your code will work.
Try indexing your string like so.