Showing posts with label Strings. Show all posts
Showing posts with label Strings. Show all posts

Wednesday, June 10, 2015

Reverse each word in a sentence - Python

# your code goes here

st = "This is awesome!"

st1 = st.split(" ")
st2 = ''
st3 = []

print st1

for y in st1:
#print y
ls = len(y)
for x in range(len(y)):
st2 = st2 + y[ls - 1 -x]
st2 = st2 + ' '
st3.append(st2)
print ' '.join(st3)

Reverse a sentence in python

st = "This is awesome!"
st1 = ''
ls = len(st)
for x in range(len(st)):
st1 = st1 + st[ls - 1- x]
print st1