Python - How come the length of this function is 1?
my_courses = {'course1': 'html', 'course2': 'css'} def pyc(**dict): result = [] for kw in dict.keys(): for i in dict[kw]: if i in 'python': result.append(dict[kw]) break return result print(len(pyc(**my_courses))) # how did we get an output of 1? From my understanding: - we're passing {'course1': 'html', 'course2': 'css'} into the pyc function - in the outer for loop, course 1 and course2 are the items (kw) in dict.keys() - in the inner for loop, dict is the name of a list (with course1 and course2 as list items) - the if statement's condition is "if course1 or course2 is in the string 'python' (DON'T UNDERSTAND THIS) --> if the condition is true, we append course1 and course2 to the local result list - the local result list is returned as the value for pyc(**my_courses) The len() function returns the number of items in an object. This means only one of course1 or course2 had met the if statement's condition. --> it turns out that print(pyc(**my_courses)) outputs ['html'] ---> so course1 had met the condition. But why?