Write a simple program that reads a line from the keyboard and prints the same line where each word is reversed. A word is defined as a continuous sequence of alphanumeric characters or hyphens ('-). For example, if the input is "you can help me!" the output should be "naC uoy pleh em!"
I just tried with the following code, but there are some problems with it,
print"Enter the string:" str1=raw_input() print (' '.join((str1[::-1]).split(' ')[::-2]))
He prints "naC uoy pleh! Em", just look at the exclamation (!), This is the problem here. Can anyone help me ???
Anoop
source share