Challenge: Common Friends
Completed
Two people list their friends. Print the friends they have in common, sorted alphabetically. If there are none, print No common friends.
Input
Two lines, each a list of names separated by spaces.
Output
The common names in alphabetical order separated by spaces, or No common friends.
Example
Input
ravi asha meena kabir kabir zoya asha
Output
asha kabir
Editor
Python
Hints
Turn each line into a set.
& gives the items in both sets.
sorted() turns a set into a sorted list.
Solution explanation
Sets make this a one-liner: a & b is everything in both. Sort it and join it into a line.
Show solution
a = set(input().split())
b = set(input().split())
common = sorted(a & b)
print(" ".join(common) if common else "No common friends")