#Condition—There is no duplication of data.
x = {"a", "b", "c"}
y = {"c", "b", "e"}
z = {"f", "b", "c"}
result=x.intersection(y,z)
print(result)
# {'b', 'c'}
Sample Output) Please let me know if there is a recommended format.
[['b', 1, 1, 1], ['c', 2, 0, 2]}
Would you like to search for 'b', 'c'?It would be helpful if you could write in one line.
Thank you for your cooperation.
I don't know python, but I tried writing it in ruby.
Please translate it to python.
x = ["a", "b", "c" ]
y = ["c", "b", "e" ]
z = ["f", "b", "c" ]
def intersection (x, *a)
x.find_all {|i|[x,*a].all?{|j|j.include?(i)}}.collect {|i|[i]+[x,*a].collect {|j|j.index(i)}}}
end
print(intersection(x,y,z))
© 2024 OneMinuteCode. All rights reserved.