Ca 2 Pyt
Ca 2 Pyt
Ca 2 Pyt
OUTPUT
Q.4
#on a string containing at least five words, Store the string in a variable
# #Use function to extract all the unique words from the string
# #Convert Each word to title Case.
#Cocatenate all the title case words into a single string, sepearate by
commas.
#print out the resulting string.
str="MY name is Abhishek, Abhishek is good at python basics"
print(str)
words= str.strip()
def unique (words):
words_list = [word. strip().lower() for word in words.split() if
word.isalnum()]
unique_words = set(words_list)
return unique_words
text = "MY name is Abhishek, Abhishek is good at python basics!"
unique_words = unique (text)
print("Unique words:", unique_words)
words = str. split()
title_cased_words = []
for word in words:
title_cased_words. append (word.title)
print(title_cased_words)
separator_string = ','
result = ''.join(title_cased_words)
print(result)