Extraterrestrial python solution | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Extraterrestrial python solution

I’ve created the code which produces a correct output for test case 2 but I don’t know how to advance to produce for all 5 test cases. Any advice appreciated. def greeting(): return ("bathroom") print (greeting()[::-1])

26th Mar 2020, 9:11 PM
James Johnson
4 Answers
+ 6
You get input from the user via the input() method. Try creating a variable equal to input, reversing it, then printing it 🙂
26th Mar 2020, 9:22 PM
Clayton C.
Clayton C. - avatar
+ 5
print(input()[::-1]) The input() seeks user input while the [::-1] is a standard Python trick for reversing a string. Hope this helps!
26th Mar 2020, 10:35 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 2
First define a function with argument x to return x [::-1] that is for reversing the string then take input from user as x= input(" ") Then print the function.Thats it!
25th May 2020, 8:33 AM
Sarath S
Sarath S - avatar
0
Just based on the Introduction to Python I created this code: word = input() length = len(word) answer= "" while length > 0: answer = answer + word[length-1:length] length = length-1 print(answer)
3rd Jul 2023, 3:05 PM
BrightJ
BrightJ - avatar