id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

david.white@denison.edu cs112fall2015 > intersect
prev  |  next  |  chance

Write a function intersect(data1, data2) that returns True if the two lists named data1 and data2 have any common elements, and False otherwise. For example, intersect([’Katniss’, ’Peeta’, ’Gale’], [’Foxface’, ’Marvel’, ’Glimmer’]) should return False, but intersect([’Katniss’, ’Peeta’, ’Gale’], [’Gale’, ’Haymitch’, ’Katniss’]) should return True.


intersect([1, 2, 3, 4, 5], [2, 4, 6, 8, 10]) → True
intersect(['a', 'b', 'c', 'd', 'e'], ['f', 'f', 'h', 'i', 'j']) → False
intersect(['Bart', 'Lisa', 'Homer', 'Marge', 'Maggie'], ['Peter', 'Meg', 'Stewie', 'Lois', 'Chris']) → False

...Save, Compile, Run (ctrl-enter)

def intersect(data1,data2):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Copyright Nick Parlante 2017 - privacy