forked from hariom20singh/python-learning-codes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathString_slicing.py
More file actions
16 lines (10 loc) · 753 Bytes
/
String_slicing.py
File metadata and controls
16 lines (10 loc) · 753 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
str1 = "Lokesh is learning python"
print(str1)
# print(str1[:6]) print "Lokesh" because it's starting default value is 0
# print(str1[0:]) print "Lokesh" because it's Last default value is string length
# print(str1[:]) print complete string becuse starting default value is 0 and last value is string length
# print(str1[1]) print o because index start from 0
# print(len(str1)) print string length
# print(str1[0:6]) print Lokesh and in this 0 is included and 6 is exclude it will go from 0 - (n-1), so we have to give 1 extra index
# print(str1[0:25]) print complete string
# print(str1[0:6:2]) print "Lks" because first it will go from[0:6] that is lokesh and then[0:6:2] means leave multiple of two or every second character.