Python has two ideas for realizing string output in reverse order:
1. Write a loop to implement
Take one character of the string each time, from It can be taken from the last to the front and can be output directly, or it can be added to a new string and output together at the end.
Specific code:
m = list(a) for i in range(len(a)-1,-1,-1): print(m[i],end = '')
2. Use slicing to implement
print(a[::-1])
Recommended tutorial: python tutorial
The above is the detailed content of python implements string output in reverse order. For more information, please follow other related articles on the PHP Chinese website!