Here are some possible manipulations using string methods:
>>> a = 'java python c++ fortran'
>>> a.isalpha()
False
a.isalpha()
is False
because of the spaces and '++'
.
>>> b = a.title()
>>> b
'Java Python C++ Fortran'
>>> c = b.replace(' ', '!\n')
>>> c
'Java!\nPython!\nC++!\nFortran'
>>> print(c)
Java!
Python!
C++!
Fortran!
>>> c.index('Python')
6
>>> c[6:].startswith('Py')
True
>>> c[6:12].isalpha()
True
(Note that \n
is a single character.)