I am trying to create a small program that prompts the user to input 3 words, then put the string inputs into an array, then sort the array lexicographically and print the array as a string list.
I have tried the .sort function which does not work. The project I am working on does not require knowledge of loops (which I do not have a lot of experience with yet).
a = []
first = input("Type a word: ")
second = input("Type another word: ")
third = input("Type the last word: ")
a += first
a += second
a += third
a = sorted(a)
print(a)
I want the printed results to be the 3 words together separated by commas
Apple, Banana, Egg
Instead, my code prints
['A', 'B', 'E', 'a', 'a', 'a', 'e', 'g', 'g', 'l', 'n', 'n', 'p', 'p']