Python Strings
Strings
Strings can be enclosed in single quotes (‘..’) or double quotes (“..”). The print() function is used to show the output of strings.
Examples
Single quotes
>>> 'Single quotes test' 'Single quotes test'
Double quotes
>>> "Double quotes test" 'Double quotes test'
Single and Double quotes in a string
>>> '"Single" and "Double" quotes in a string' '"Single" and "Double" quotes in a string'
Assigns string to a variable
>>> mystring = 'Assigns string to a variable' >>> print(mystring) Assigns string to a variable >>> x = 'New line.\nExample.' >>> print(x) New line. Example.
String concatenate
>>> test = 'String concatenate ' >>> test + 'example!' 'String concatenate example!'