-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrings.py
More file actions
39 lines (31 loc) · 881 Bytes
/
strings.py
File metadata and controls
39 lines (31 loc) · 881 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
37
38
# single line string with double quote
course = "Learning single line string with double quote"
print(course)
# single line string with single quote
course = 'Learning single line string with single quote'
print(course)
# multiple line string with double quote
course = """
Hi,
This is Larry.
Learning multiple line string with double quote
Thanks
"""
print(course)
# multiple line string with single quote
course = '''
Hi,
This is Larry.
Learning multiple line string with single quote
Thanks
'''
print(course)
# get char using index
course = "Python for Beginners"
print(course[0]) # 0 is starting point
print(course[-1]) # -1 is ending point
# we can tell start point and length of char using colon (:)
print(course[0:3])
print(course[:5]) # default starting point 0
print(course[2:]) # print rest of all chars
print(course[1:-1]) # print index 1 to exclude last 1