iterate over a word in reverse and access each character in python code example
Example 1: reverse each word in a string python
def reverse_word_sentence (sentence):
return ' '.join(word[::-1] for word in sentence.split(" "))
# Input: "Split Reverse Join"
# Output: "tilpS esreveR nioJ"
Example 2: reverse words in a given string
function reverse (word) {
word = word.split('.').reverse().join('.')
return word
}
word = 'i.like.this.program.very.much'
word = 'pqr.mno'
console.log(reverse(word))