-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSlicing.py
52 lines (40 loc) · 1.03 KB
/
Slicing.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
planet1="Closest of Sun"
print(planet1)
"""
print(planet1[0])
print(planet1[1])
print(planet1[2])
print(planet1[-1])
print(planet1[-2])
print(planet1[-3])
# Slicing a string, get a substring from a string
print(planet1[1:4])
print(planet1[:])
print(planet1[:7])
print(planet1[11:])
# Slicing Tuple
devops=("Linux", "Vagrant", "Bash Scripting", "AWS", "Jenkins", "Python", "Ansible")
print(devops[0])
print(devops[4])
print(devops[-1])
print(devops[2:5])
print(devops[2:5][0])
print(devops[2:5][0][5:11])
print(devops[2:5][0][5:11][-1])
# Slicing List
devops=["Linux", "Vagrant", "Bash Scripting", "AWS", "Jenkins", "Python", "Ansible"]
print(devops[0])
print(devops[4])
print(devops[-1])
print(devops[2:5])
print(devops[2:5][0])
print(devops[2:5][0][5:11])
print(devops[2:5][0][5:11][-1])
"""
# Dictionary Example
Skills = {"DevOps": ("AWS", "Jenkins", "Python", "Ansible"), "Development": ["Java", "NodeJS", ".net"]}
print(Skills)
print(Skills["DevOps"])
print(Skills["Development"])
print(Skills["DevOps"][-1])
print(Skills["DevOps"][-1][:3])