+ 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
5 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
you also can write this code: letter = input() alian_letters = [] i = 1 for counter in range(len(letter)): alian_letters.append(letter[len(letter)-i]) i += 1 word = ''.join(alian_letters) print(word) this is easier for me but also too much lines. i hope this help you.
4th Mar 2022, 6:41 AM
Luka Gujabidze
Luka Gujabidze - 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