Reputation: 17
Sample user input
letters = input("Please input the scrambled letters in order: ")
Now we all know that there are only 26 letter in english and none of them repeat. So how do I make sure that whatever the user inputs doesn't repeat(don't need to replace)? I need to write an if statement with that algorithm.
if letters == nothing_duplicate:
do something
Upvotes: 1
Views: 86
Reputation: 67103
If you want to check for duplicates and verify that they have input every letter:
import string
if set(letters.lower()) == set(string.lowercase):
# do something
To actually get the list of letters that are missing, you could do something like this:
>>> set(string.lowercase).difference('abcdefghijklmnopqrst')
set(['u', 'w', 'v', 'y', 'x', 'z'])
Upvotes: 0