example 1:
split method is used for to split the given string in the left to right direction
s="anil durgam embedded"
l=s.split()
print(l)
output:
['anil', 'durgam', 'embedded']
example2:
s="anil durgam embedded"
l=s.split()
print(l)
for x in l:
print(x)
output:
['anil', 'durgam', 'embedded']
anil
durgam
embedded
example 4:
s="03-11-2019"
l=s.split("-")
print(l)
for x in l:
print(x)
output:
['03', '11', '2019']
03
11
2019
example 5:
s="anil durgam embedded developer india"
l=s.split(" ",3)
print(l)
for x in l:
print(x)
output:
anil
durgam
embedded
developer india
example 6:
s="10 20 30 40 50 60 70 80"
l=s.split(" ",3)
print(l)
for x in l:
print(x)
output:
10
20
30
40 50 60 70 80
No comments:
Post a Comment