+ 1

Python Intermediate Course 6.2 Sets

Why this doesnt work? skills = {'Python', 'HTML', 'SQL', 'C++', 'Java', 'Scala'} job_skills = {'HTML', 'CSS', 'JS', 'C#', 'NodeJS'} #my part of code (down below) match={} for x in skills: for y in job_skills: if x == y: match.add(x) print(match)

14th Sep 2022, 1:22 PM
Lil Bebi
Lil Bebi - avatar
3 Answers
+ 6
match = {} will make empty dictionary. Use match = set() And print set elements, not entire set.
14th Sep 2022, 1:49 PM
Jayakrishna 🇼🇳
+ 5
Just as a suggestion: You can simplify your code by removing the inner loop and just check if x in job_skills. If you read the task description carefully, you'll find that they suggest you ***intersection*** to solve the task (see previous lesson on sets).
14th Sep 2022, 2:00 PM
Lisa
Lisa - avatar
+ 1
Thank you guys! Lisa yeah i know the intersect operator and already had the solution with it. I just wondered how the code behind it works to get a better understanding.
19th Sep 2022, 10:11 AM
Lil Bebi
Lil Bebi - avatar