16.2. Working with Strings¶
A string is a collection of characters, in a sequence.
"My name is Mark." is a string with 16 characters in it. Spaces and periods are separate characters.
Strings start with single quotes or double quotes. As you have seen before you can actually do some simple “arithmetic” with strings using
* as shown below. You can also get the length of any collection (including strings) with the
Remember that strings must start and end with the same character. That character can be
', but whatever you use as the starting character must match the ending character.
Run the code below to see what type of error you get if you use a different starting character than ending character in a string. Then try to fix the 2 errors in the code and run the code again. You should get the same results as in CodeLens 1 (String_Manip) above.
Do ‘simple arithmetic’ with the variables provided below to print ‘jellybeanjellybeanjellybean’.
Discuss topics in this section with classmates.