On 9 August 2013 23:27, wrote:
This is what I ended up with btw. Does this insult anyone's more well attuned Python sensibilities?
You didn't listen to any of the advice we've been giving you. You've
had *much* better answers given than this.
Start from the top.
We need letters, so define that:
letters = "abcdefghijkl"
We then want to loop, possibly forever. A good choice is a "while" loop.
# True is always True, so will loop forever
We then want to ask for a letter. We want to use "input". Write
"help(input)" in the Python Shell and you get
Help on built-in function input in module builtins:
input([prompt]) -> string
Read a string from standard input. The trailing newline is stripped.
If the user hits EOF (Unix: Ctl-D, Windows: Ctl-Z+Return),
On Unix, GNU readline is used if enabled. The prompt string, if given,
is printed without a trailing newline before reading.
So our line should be:
letter = input("Type a letter from 'a' to 'n' in the alphabet: ")
Then we want to test if it's on of our letters:
if letter in letters:
And if so we want to say something positive:
If not we want to say something negative:
And then we want to ask if we should go again:
go_again = input("Do you want to do this again? ")
If the response is "y" or "yes", we want to continue looping. The
while loop will do that automatically, so we can do nothing in this
If the response in *not* "y" or "yes", we want to stop:
if go_again not in ("y", "yes"):
That's it. No need to complicate things. Just take it one step at a time.