Respuesta :
Answer:
The program to this question as follows:
Program:
value = input("Input text value: ") #defining variable value and input value by user
word = value.split() #defining variable word that split value
sort_word = sorted(word) #defining variable using sorted function
unique_word = [] #defining list
for word in sort_word: #loop for matching same value
if word not in unique_word: #checking value
unique_word.append(word) #arrange value using append function
print(' '.join(unique_word)) #print value
Output:
Input text value: Good morning Good afternoon Good evening
Good afternoon evening morning
Explanation:
In the above python code, a value variable is defined that uses input function to input value from the user end, and the word variable is declared, which uses the split method, which split all string values and defines the sort_word method that sorted value in ascending order.
- Then an empty list "unique_word" is defined, which uses the for loop and inside the loop, a conditional statement is used.
- In if block, it matches all value is unique if this is condition is true it will arrange all values and uses the print function to print all value.
The program returns unique elements in the string passed in with no duplicates. The program is written in python 3 thus :
text = input('Enter text : ')
#prompts user to enter string inputs
split_text = text.split()
#split inputted text based on whitespace
unique = set(split_text)
#using the set function, take only unique elements in the string
combine = ' '.join(unique)
#use the join function to combine the strings to form a single length string.
print(combine)
A sample run of the program is attached
Learn more : https://brainly.com/question/15086326
