Answer:
def texted():
text= input("Enter Text: ")
text = text.lower()
nlist = ' '
for char in text:
if char.isalnum() == True:
if char not in nlist:
nlist = nlist + char
nlist = sorted(nlist)
print(nlist)
return;
texted()
Step-by-step explanation:
Step 1:
Define the function, i.e give it a name.
def texted():
Step 2:
Prompt the user to input a string i.e Text
text= input("Enter Text: ")
Step 3:
use the lower() string method. it is a method in python used to convert uppercase string characters to lower case.
text = text.lower()
Step 4:
Declare an empty string variable that will be used to store the characters while sorting.
nlist = ' '
Step 5:
for char in text:
if char.isalnum() == True:
if char not in nlist:
nlist = nlist + char
-Use a for loop to iterate through all the characters in the text.
-.isalnum() is a method in python that returns true if a character is an alphabet or a number.
The first if statement checks if it is an alphabet or a number and if it passes as true, it passes that alphabet or number to the next if statement.
- The second if statement checks if the character is not already in the list, if it is in the list it would not add it a second time.
If the character is not in the list, it adds the character to the list.
Step 6:
- sorts the list, i.e arranges the list in an alphabetical order.
- prints out the list, i.e produces an output of the list to your computer screen.
nlist = sorted(nlist)
print(nlist)
- texted() this is used to call the function.