+ 3
Is there a better idea than this?
I have just done a python code called "backward the string" and I think there's a better way than the code I have made. So... https://code.sololearn.com/cYxrc1q2pTJk/?ref=app
1 Answer
+ 3
The input() function returns a string so don't have to enclose it inside str(), there's also a clever list slicing trick that reverses a collection in a single line of code
collection[::-1]
So you could do a one liner...
print(input()[::-1])
Edit: I decided to use a for loop and came up with this (not the most efficient way but simple):
https://code.sololearn.com/cxbwGCKj8Yqj/?ref=app
It has 2 strings the input and the new reversed string the for loop goes over the input and inserts the characters at the start of the new string.