Python Python Basics (2015) Shopping List App Continue

Conner Williams
PRO
Conner Williams
Pro Student 3,305 Points

Is this anywhere near being correct?

after taking some time to think about this one, I feel I might be getting somewhere. Still completely unsure though.

breaks.py
def loopy(items):
    # Code goes here
    for item in items:
        print(item)
    if index(0) == 'a':
        continue
    else:
        print(current number)

2 Answers

Steven Parker
Steven Parker
171,108 Points

You won't need the "else" or the second "print" (plus that phrase "current number" doesn't mean anything to the program).

Then you need to re-order your lines so the test is done before the print, and indent the test more to put it inside the loop.

Finally, instead of "index(0)" you need "item[0]" to get the first letter of the item.

I'll bet you can get it now without an explicit code spoiler.

Haydar Al-Rikabi
Haydar Al-Rikabi
5,965 Points

To demonstrate Steven's reply, see the following code:

def loopy(items):
    for item in items:
        if item[0] == 'a': # Use square brackets [] rather than parentheses ()
            continue
        print(item) # If the condition above fails, then this line is executed