+ 1

What mistake am I doing?

Reverse word if word length is odd else print the same word https://code.sololearn.com/c9az5I6BGROQ/?ref=app

19th May 2020, 5:56 AM
Karthik
Karthik - avatar
3 Answers
+ 4
return [' '.join(i) if len(i)%2==0 else i[::-1] for i in word.split()] the most outer brackets 😉
19th May 2020, 6:21 AM
Oma Falk
Oma Falk - avatar
+ 3
btw return [i if len(i)%2==0 else i[::-1] for i in word.split()] is shorter
19th May 2020, 6:51 AM
Oma Falk
Oma Falk - avatar