+ 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 ?
10 Answers
+ 9
You can use reversed() function instead.
print("".join(list(reversed(input()))))
+ 4
#shortest solution
print(input ()[::-1])
+ 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.
+ 1
I should use list() then pust the value , then reverse it then print the result 💞
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().
0
Jayakrishna🇮🇳 how ?
- 1
I have a idea 💡
- 1
ravilnicki i know this but i am trying another codes
- 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...