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 Data Science Basics Cleaning Data Clean Up Your Data

data science basic

Please example this code ,I am getting it. What is the aim of writing this code? what output do we expect?

1 Answer

check out this code (the output of the code may be different but the aim of the code is to filter the search_term):

from s2v5 import * def pattern_match(list,search_term): array = [] for row in list: if search_term in row[7]: array.append(row[1]) return array

reader = pattern_match(my_csv, b'cashmere') print(reader)

above code filters out the 'search_term' and returns the id of the ties having that particular search in the form an array. Note here the string search_term is passed in the form a byte object, because the file is read in byte objects.