+ 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])
5 Respuestas
+ 6
You get input from the user via the input() method. Try creating a variable equal to input, reversing it, then printing it 🙂
+ 5
print(input()[::-1])
The input() seeks user input while the [::-1] is a standard Python trick for reversing a string.
Hope this helps!
+ 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!
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.
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)