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 trial

Python Python Basics (2015) Shopping List App Continue

Carl Harris
Carl Harris
1,429 Points

Error message

I keep getting the error message can't convert 'int' object to string implicitly. I've tried wrapping the item variable on line 4 in an str function and I still get the error. Totally stuck here!

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

1 Answer

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Carl;

In Python, the index() method determines if a string occurs in a given string and returns the index value if found. So, for example:

string_1 = "This is a sample."
string_2= "sam"

print(string_1.index(string_2))

Would return 10 as that is the start of the index position in which string_2 is found inside string_1.

For this challenge you should be looking to see if the character "a" is at index 0. Since a string or list in Python is a sequence type you can access the index using []. For example, string_1[13] would be the character "p". You can use it in a similar fashion for lists.

Post back if you are still stuck.

Happy coding.