Things You Can Do With Strings
Length of a String: len()
l
Getting a Single Character
Try the following in the IDLE shell:

You can get any single character from a string by using a square bracket around an index. Note that indexing of a string starts from 0.
Getting a part (slice) of a string
When thinking about string indexes for slices of strings, it's easiest to think of the string in numbered cells like in this diagram:

Try out the following to get parts of the string:

Notice how when you want the beginning of a string, you don't need to type the 0 index, but can just put [:5] and when you want the end of the string, you don't need to put the last index [5:]
If you want an exact copy of your string, you can use the following:

Here are some other things you can do:
Multiply sections of string:

Change to upper case

Change to lower case

Replace parts of the string

Find the first and last letter alphabetically in a string

![]() |
|
Words without Vowels (and more for loops)
Twyndyllyngs is an obsolete English word that doesn't contain any vowels (aeiou). There are a few others, but not too many. We are going to use Python to remove vowels from sentences we type in to see if we can still read them.
Type in the example below, save it and run it, and try to understand how it works. Take careful note of how the for loop is set up.

![]() |
These lines get the input from the user, then initialise the variables. |
![]() |
This for loop will take each item in the string one at a time and store it in a variable called letter. |
![]() |
This checks that the letter is not a vowel, and then if it isn't a vowel it rewrites new_message with the letter on the end. |
![]() |
|
![]() |
|







