+ 4

Extra-Terrestrials

You meet a group of aliens, and their language is just like English except that they say every word backwards. How will you learn to communicate with them? Task: Take a word in English that you would like to say, and turn it into language that these aliens will understand. Input Format: A string of a word in English. Output Format: A string of the reversed word that represents the original word translated into alien language. Sample Input: howdy Sample Output: ydwoh My code is => print(input().split(" ").reverse().join(" ")) Why don't work ?

7th Mar 2022, 3:25 PM
Shai Shab
Shai Shab - avatar
10 Réponses
+ 9
You can use reversed() function instead. print("".join(list(reversed(input()))))
7th Mar 2022, 4:24 PM
Simba
Simba - avatar
+ 4
#shortest solution print(input ()[::-1])
8th Mar 2022, 12:29 PM
Pythøñ Cúltîst⚔️🔥🇳🇬
Pythøñ  Cúltîst⚔️🔥🇳🇬 - avatar
+ 3
I know it is Python, but I wouldn’t do this in one line. Try splitting up your code into several steps. It is easier that way to debug and find the issue.
7th Mar 2022, 3:39 PM
Brave Tea
Brave Tea - avatar
+ 1
I should use list() then pust the value , then reverse it then print the result 💞
7th Mar 2022, 3:46 PM
Shai Shab
Shai Shab - avatar
0
Input is single word so no need split(). or use a regex to split by every single character. but problem with reverse() method return none (edit) edit: Shaishab Chandra Shil [Active] input().split(" "). return a list of single value as input is a single word. so on single input, no need of split. reverse() method does not return anything. it modifies original list. so on "none", you are applying join().
7th Mar 2022, 3:36 PM
Jayakrishna 🇮🇳
7th Mar 2022, 3:39 PM
Shai Shab
Shai Shab - avatar
- 1
I have a idea 💡
7th Mar 2022, 3:41 PM
Shai Shab
Shai Shab - avatar
- 1
ravilnicki i know this but i am trying another codes
7th Mar 2022, 4:16 PM
Shai Shab
Shai Shab - avatar
- 1
Your way of trying : i = list(input()) i.reverse() #nothing returns. do changes on i print(''.join(i)) Yes. For single line : print(''.join(reversed(input()))) May there other ways...
7th Mar 2022, 4:43 PM
Jayakrishna 🇮🇳