concept letter in category python

appears as: letter, letters, letters, letter, The letters
Tiny Python Projects: Learn coding and testing with puzzles and games

This is an excerpt from Manning's book Tiny Python Projects: Learn coding and testing with puzzles and games.

An easier way to determine if char is a vowel would be to use Python’s x in y construct, which will tell us if the value x is in the collection y. We can ask whether the letter 'a' is in the longer string 'aeiou':

>>> 'a' in 'aeiou'
True

def main():
    args = get_args()
    for letter in args.letter:
        print(letter)

All this hard work writing code is getting on my nerves. I’m ready to turn to a life of crime! I’ve kidnapped (cat-napped?) the neighbor’s cat, and I want to send them a ransom note. In the good old days, I’d cut letters from magazines and paste them onto a piece of paper to spell out my demands. That sounds like too much work. Instead, I’m going to write a Python program called ransom.py that will encode text into randomly capitalized letters:

$ ./ransom.py 'give us 2 million dollars or the cat gets it!'
gIVe US 2 milLION DoLlArs or ThE cAt GEts It!


Figure 12.1 The awful program will transform input text into a ransom note by randomly capitalizing letters.
Hello World! Third Edition

This is an excerpt from Manning's book Hello World! Third Edition.

You just created a thing that’s made up of the letters “Mr. Morton”, and you gave it the name Teacher.

The equal sign (=) tells Python to assign or “make equal to.” You assigned the name Teacher to the series of letters “Mr. Morton”. A name is like a label or tag or a sticky note that you attach to something to identify what it is.

Somewhere in a chunk of your computer’s memory, the letters “Mr. Morton” exist, but you don’t need to know exactly where. You told Python that the name for that series of letters is Teacher, and that’s how you’ll refer to it from now on.

Notice that the letters are not in order. That’s because append() adds the item to the end of the list. If you want the items in order, you’ll have to sort them. We’ll get to sorting very soon.

if 'a' in letters:
    print("found 'a' in letters")
else:
    print("didn't find 'a' in letters")