# Write a program that accepts a sequence of whitespace separated words as input and
# prints the words after removing all duplicate words and sorting them
# alphanumerically
str = input("Enter a whitespace seprated string : ")
if len(str)>0:
sstr=""
wordList = str.split(" ")
wordList = sorted(wordList)
for w in wordList:
if sstr.count(w)==0:
sstr +=w
sstr +=" "
sstr = sstr[:-1]
print("Sorted String : ",sstr)
else:
print("String is empty.")
input("Press Enter to exit.")
If you have a great ability of thinking, imagination and visualisation than you have to codes your thinking and visualisation.
Wednesday, 13 June 2018
Write a program that accepts a sequence of whitespace separated words as input and prints the words after removing all duplicate words and sorting them alphanumerically using Python Programming.
Subscribe to:
Post Comments (Atom)
Featured post
To add 'ing' at the end of a given string (length should be at least 3). If the given string already ends with 'ing' then add 'ly' instead. If the string length of the given string is less than 3, leave it unchanged. <br/>Sample String : 'abc' <br/> Expected Result : 'abcing' <br/> Sample String : 'string'
#To add 'ing' at the end of a given string (length should be at least 3). If the #given string already ends with 'ing' then...
Popular Posts
-
# To implement Queue using list queueList = [] def enQueue(ele='\0'): if ele!='\0': queueList.append(...
-
# To find all prime numbers within a given range. import math n1 = int(input("Enter lower limit of range : ")) n2 = int(in...
-
# Python Program To demonstrate inheritance. # Parent Class class parentCls: def __init__(self): print("Parent Cl...
No comments:
Post a Comment