Introduction
We have used
strings before. They are assigned simply by writing the text between
single quotes,
double quotes, or
a combination of three of each to write a text on
multiple lines.
EXAMPLE
Editor - lesson_8_strings.py
|
|
DETAILS
The data type is
str, meaning a
string of characters (in a simple form, a
string).
Python has the ability to
adapt, so assignments without explicitly imposing the type automatically lead to the creation
of
str objects.
We also know that the
input() function reads a string of characters entered by the user from the keyboard and returns it as
a
str type. The read data must eventually be
explicitly converted to a data type for processing,
otherwise, we may encounter interpretation errors:
Good. Let's see what more we can do!
Note. In other programming languages, there is the
char type, which holds
a single character - Python
does not offer this because it is considered that we can define a string of characters with a length of
1 –
simple.
Run the program then proceed to the next page.