Common interest tags
Write code · Basic · §4.1 Remembering what you have seen
You are given a and b, the interest tag lists of two people. Complete the function solution, which returns a list of the tags that both people have, sorted in ascending order, the way sorted() sorts strings.
Even if the same tag appears several times in one person's list, include it only once.
Function
solution(a, b)
Constraints
- The lengths of
aandbare each from 1 to 100,000. - Each tag is a string of lowercase English letters and digits, with a length from 1 to 10.
Examples
| a | b | result |
|---|---|---|
['ai', 'music', 'travel', 'ai'] | ['travel', 'food', 'ai'] | ['ai', 'travel'] |
['cat'] | ['dog'] | [] |
Starter code
def solution(a, b):
answer = []
return answerSolve this problem in your browser
Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.