Python: Reverse all the words which have even length
Python Basic - 1: Exercise-113 with Solution
Write a Python program to reverse all words of odd lengths.
def reverse_even(txt): return ' '.join(i[::-1] if not len(i)%2 else i for i in txt.split()) print(reverse_even("The quick brown fox jumps over the lazy dog")) print(reverse_even("Python Exercises"))
The quick brown fox jumps revo the yzal dog nohtyP Exercises
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join