Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python

bright chibuike
bright chibuike
3,245 Points

instances objective 1

what could be the answer to this question . here is my code i have written:

def combiner(data): data =["apple",5.2,"dog",8] data1 = data[::2] data2 =data[1::2] if isinstance(data1,(str)) ==True and isinstance(data2,(int,float)) ==True: return sum(data1,data2)

instances.py
def combiner(data):
    data =["apple",5.2,"dog",8]
    data1 = data[::2]
    data2 =data[1::2]
    if isinstance(data1,(str)) ==True and isinstance(data2,(int,float)) ==True:
        return sum(data1,data2)

1 Answer

Steven Parker
Steven Parker
216,108 Points

Here's a few hints:

  • don't overwrite the data with a literal, use the "data" as provided by the caller
  • don't make any assumptions about the contents or order that the provided data will have
  • you can expect the actual test data will not be the same as the example that was shown
  • you will probably need a loop and probably not need slices