String slicing can be used to exchange the positions of two adjacent characters in Python: str = "Python" str = str[1] + str[0] + str[2:] print(str) After the exchange is completed, the output is: ytonsP
How to swap the positions of two adjacent characters in python
Guess you like
Origin blog.csdn.net/weixin_42592399/article/details/129445555
Recommended
Ranking