Strings 1) : Scan The Text and Print Out All Characters Which Are Between Square Brackets
Strings 1) : Scan The Text and Print Out All Characters Which Are Between Square Brackets
1] Count how many of each vowel (a, e, i, o, u) there are in a text string, and print the count
for each vowel with a single formatted string. Remember that vowels can be both lower and
uppercase.
4] In the text below, count how often the word “wood” occurs (using pro-gram code, of
course). Capitals and lower case letters may both be used, and you have to consider that the
word “wood” should be a separate word, and not part of another word. Hint: If you did the
exercises from this chapter, you already developed a function that “cleans” a text. Combining
that function with the split() function more or less solves the problem for you.
5] Write a program that takes a string and produces a new string that con-tains the exact
characters that the first string contains, but in order of their ASCII-codes. For instance, the
string "Hello, world!" should be turned into " !,Hdellloorw". This is relatively easy to do with list
functions, which will be introduced in a future chapter, but for now try to do it with string
manipulation functions alone.
6] Typical autocorrect functions are the following: (1) if a word starts with two capitals,
followed by a lower-case letter, the second capital is made lower case; (2) if a sentence
contains a word that is immediately followed by the same word, the second occurrence is
removed; (3) if a sentence starts with a lower-case letter, that letter is turned into a capital; (4)
if a word consists entirely of capitals, except for the first letter which is lower case, then the
case of the letters in the word is reversed; and (5) if the sentence contains the name of a day
(in English) which does not start with a capital, the first letter is turned into a capital. Write a
program that takes a sentence and makes these auto-corrections. Test it out on the string
below.
sentence = "as it turned out our aRTHUR chance meeting with REverend \ our
BElling was was to change every sunday we whole way of life , and \ St lOONY up
' d hurry along to and Jam ..." the Cream BUn \