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])
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 🙂
+ 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
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)