1def swap(string, i, j):
2 """
3 Swapping between 2 given indices of a chars in a string
4 :param string: string
5 :param i: first index
6 :param j: second index
7 :return: new string with the swapped chars
8 """
9 string = list(string)
10 string[i], string[j] = string[j], string[i]
11 return ''.join(string)
12
13# EXAMPLE
14str = "example"
15print(swap(str, 0, 1)) # print "xeample"