0
Print the value not the Set
I want to print out the value of the union between two sets. But instead my code prints the Set itself. The desired output is: HTML not {'HTML'} https://code.sololearn.com/c2A9a21A3a7A
4 Answers
+ 2
print(*(skills & job_skills))
+ 2
skills = {'Python', 'HTML', 'SQL', 'C++', 'Java', 'Scala'}
job_skills = {'HTML', 'CSS', 'JS', 'C#', 'NodeJS'}
x = list(skills & job_skills)
z = ' '.join(x)
print(z)
+ 1
I found this solution:
skills = {'Python', 'HTML', 'SQL', 'C++', 'Java', 'Scala'}
job_skills = {'HTML', 'CSS', 'JS', 'C#', 'NodeJS'}
match = (skills & job_skills)
for x in match:
print(x)
But I like the solution from @visph better. Thank you.
+ 1
roughly, my solution does the same thing, but shorter:
* here is the destructuring operator... it send all items of an iterable as arguments to the print() function, wich has the space as default separator ;)