fb pixel

set comprehension

Much like list comprehension, set comprehension also allows to create a set with a single line of code. The only difference is the use of curly brackets {} instead of [].
s = set()
for i in range(10):
	s.add(i**3)
print(s)
s = {i**3 for i in range(10)}
print(s)
Both of the programs will print exactly the same output: {0, 1, 64, 512, 8, 343, 216, 729, 27, 125}.

Challenge

Given n words, you are asked to print all the unique last letters of those words in increasing order. To sort the set/list you can use the sorted() function.
The input contains a single line of space-separated words.
The program should print a single line of space-separated unique letters in increasing order.
Input
Output
abc def ghi
c f i
hello, how are you doing?
, ? e u w
Can you solve this in a single line 😎?
 
To check your solution you need to sign in
Sign in to continue