Strings -- exercises
- Create a string. Print it.
- Create a multi-line string. Print it.
- Concatenate two strings together. Print the result.
- Print the length of one of your strings.
- Search one string for a sub-string. Print the location of the
sub-string.
- Format a string using the string formatting operator (%).
Interpolate into the string: (1) a string, (2) an integer, and
(3) a float.
- Left justify a short string within a longer field. Print it. Do
the same but right justify it. Print it. Center the string
within a longer field. Print it.
- Strip white-space off (1) the left side, (2) the right side, and
(3) both sides of a string. Print each result.
- Split a string into a list of words.
- Join a list of strings together with "::" between each of the
sub-strings.
- Given a word and a list of strings, write a function
collect(word, strings) that returns a (new) list that
contains the strings that contain the word.
What you will learn:
- How to create and manipulate strings.
- How to concatenate two strings.
- How to format a string with the string formatting operator.
- How to justify a string.
- How to strip white-space off a string.