#!/usr/bin/python
name = "Balasubramaniam Natarajan"
print name
print "The length of the name variable is :", len(name)
#We can print characters forward.
print name[0]
# the colon dentoes through, 0 is the first character we need and 4 is one before the last character.
print name[0:4]
print name[16:25]
#The next line of for loop should be indented if not we would get an error.
for letter in name:
print letter
name2 = "Revathi Balasubramaniam"
if name == name2:
print "The two names Match"
bala@bala-laptop:~/python$ python 6Stringi.py
Balasubramaniam Natarajan
The length of the name variable is : 25
B
Bala
Natarajan
B
a
l
a
s
u
b
r
a
m
a
n
i
a
m
N
a
t
a
r
a
j
a
n
name = "Balasubramaniam Natarajan"
print name
print "The length of the name variable is :", len(name)
#We can print characters forward.
print name[0]
# the colon dentoes through, 0 is the first character we need and 4 is one before the last character.
print name[0:4]
print name[16:25]
#The next line of for loop should be indented if not we would get an error.
for letter in name:
print letter
name2 = "Revathi Balasubramaniam"
if name == name2:
print "The two names Match"
bala@bala-laptop:~/python$ python 6Stringi.py
Balasubramaniam Natarajan
The length of the name variable is : 25
B
Bala
Natarajan
B
a
l
a
s
u
b
r
a
m
a
n
i
a
m
N
a
t
a
r
a
j
a
n
No comments:
Post a Comment