Saturday, August 6, 2011

Python Strings2

#!/usr/bin/python

import string

name = "balasubramaniam natarajan"

#Type "import string" at the python command prompt so that we can manipulate
#strings with greater flexibility.

print name

name = string.upper(name)

print "The string in upper case is :",name

name = string.lower(name)

print "The string in lower case is :",name

print "The string in Capitalization is :", string.capitalize(name)

print "The string in Capwords is :", string.capwords(name)

split = string.split(name)

print split

print "The joined value is :",string.join(split)

******************************************************************************
bala@bala-laptop:~/python$ python 7Stringii.py
balasubramaniam natarajan
The string in upper case is : BALASUBRAMANIAM NATARAJAN
The string in lower case is : balasubramaniam natarajan
The string in Capitalization is : Balasubramaniam natarajan
The string in Capwords is : Balasubramaniam Natarajan
['balasubramaniam', 'natarajan']
The joined value is : balasubramaniam natarajan
bala@bala-laptop:~/python$


No comments:

Post a Comment