I am stuck in Python Developer, Collection Types, Sets Practice | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

I am stuck in Python Developer, Collection Types, Sets Practice

Two sets need to be intersected. One set is skills and the other is job_skills. My code reads: print(skills & job_skills) My Output is: {'HTML'} Whis is the correct output when working with sets. The Expected Output is: HTML How? So my code is flagged as buggy and I cannot continue. And I am running a 323 days streak, which will be broken.

28th Oct 2023, 2:23 PM
Kennard Nahar
Kennard Nahar - avatar
2 Respostas
+ 4
Do this print(*(skills & job_skills))
28th Oct 2023, 3:26 PM
AĶ¢J
AĶ¢J - avatar
+ 4
The reason the answer given by AĶ¢J works is because the '*' tells python to unpack the Set. Otherwise, you are just creating a new set and would need to iterate through it to get the correct output.
28th Oct 2023, 4:59 PM
Keith
Keith - avatar