Skip to content

Commit 20f4cfd

Browse files
Exercise_8
1 parent 91b74a8 commit 20f4cfd

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

.idea/workspace.xml

Lines changed: 5 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Solution.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,26 @@ def prog_3():
177177
print(list_)
178178
return
179179

180+
181+
182+
# ========================= Question_7: ===========================================
183+
# Write a program that accepts a sequence of whitespace separated words as input and prints the words
184+
# after removing all duplicate words and sorting them alphanumerically.
185+
# Suppose the following input is supplied to the program:
186+
# hello world and practice makes perfect and hello world again
187+
# Then, the output should be:
188+
# again and hello makes perfect practice world
189+
#
190+
# Hints:
191+
# In case of input data being supplied to the question, it should be assumed to be a console input.
192+
# We use set container to remove duplicated data automatically and then use sorted() to sort the data.
193+
194+
def prog_4():
195+
x = input()
196+
set_ = set((x.split()))
197+
list_ = [x for x in set_]
198+
list_.sort()
199+
print(" ".join(x for x in list_))
200+
prog_4()
201+
202+
print("=============================================")

0 commit comments

Comments
 (0)