I need this for my homework. I'm trying to create a a program where I ask the user for some words. I want those words to be on a list so then I can use .index
to call some.
I tried to use .set
or sorted(set())
. It worked with numbers but not words. For instance:
x = list (raw_input ("insert numbers"))
set = set(x)
result = list(set)
result.sort()
print result
From this, I get some good results. If I feed it numbers, I get the output I expect:
insert numbers 817654
[' ', '1', '4', '5', '6', '7', '8']
If I enter words, it sorts the letters:
insert numbers now i will a rhyme construct ...
[' ', '.', 'a', 'c', 'e', 'h', 'i', 'l', 'm', 'n', 'o', 'r', 's', 't', 'u', 'w', 'y']
The output I want is
['a', 'construct', 'i', 'now', 'rhyme', 'will']