0
How to swap two characters in string in python?
'ab-cd' ==> 'cd-ab' | 'ba-dc'
7 Respuestas
+ 3
You can for example split your string in a list and change the position of it items. After that concatenate to a string.
+ 3
For it Mahmoud ayman you could learn all inbuild functions for a string. By the way this can be solved i.e. as in this code:
https://code.sololearn.com/c1dyR8Nhx4zp/?ref=app
+ 1
This function is universal for swaping two items in a string. That means the position of second part will be changed to the position of first part of its string etc. For this you have to set in addition the beginning of first as well as the second parts.
+ 1
Store the two strings in variables named x and y, and then write:
x,y=y,x
0
JaScript I want to do that without using list
0
JaScript is that function to solve just my example?
0
JaScript I get it but the function is a little confused