-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathStrings.py
More file actions
36 lines (27 loc) · 878 Bytes
/
Strings.py
File metadata and controls
36 lines (27 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Strings reference guide / tutorial for Python
# Print welcome message
print("Hello World")
# Strings can either be surrounded in " or '
print('Hello World')
# You can use variables to store strings, then print them out
message = "Hello World"
print(message)
# If you want to put single quotes in a single quote string or double quotes in a double quote string, you need to change the string's quote type
# Invalid: 'hello's world'
message = "hello's world" # Correct
# Invalid: "he said "welcome!""
message = 'he said "welcome!"' # Correct
# You can also use the backslash character to ignore quotes
message = 'mary\'s ice cream'
message = "she exclaimed \"good\" morning"
# Use three double quotes for a multiline string
message = """ hello
line1
line2
line3
...
"""
print(message)
# Different avaliable functions for strings
# | Length |
a = len("hello") # a = 5