Strings – concatenation, methods, and input()
So far, you have learned how to express numbers, operations, and variables. But what about words? In Python, anything that goes between single ('
) or double ("
) quotes is considered a string. Strings are commonly used to express words, but they have many other uses, including displaying information to the user and retrieving information from a user.
Examples include 'hello'
, "hello"
, 'HELLoo00'
, '12345'
, and 'fun_characters: !@ #$%^&*('
.
In this section, you will gain proficiency with strings by examining string methods, string concatenation, and useful built-in functions, including print()
and len()
, by covering a wide range of examples.
String syntax
Although strings may use single or double quotes, a given string must be internally consistent. That is, if a string starts with a single quote, it must end with a single quote. The same is true of double quotes...