Strings
A variable is an symbolic name that references a Python object. In this lesson, you will learn about string variables. Feel free to practice with the Python console below:
We can assign a string to a variable like so:
Multiline Variables
We can add \n to indicate a new line:
Or we can specify them like so:
String Length
When working with strings, it is common to need to limit the length of a string.
Strings are arrays!
You can access an index of any string just like an array. The example below will print the first character of the string:
This would be useful if for example if you wanted to do something like take the first and last name of a person and create a username:
Search Strings
Return true or false if a string contains a keyword:
We can us if / in to search a string for a keyword:
No comments yet. Add the first comment to start the discussion.