Every line of 'swap characters in string python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
475 def swapcase(self, s): 476 """ 477 Return a copy of *s*, but with lower case letters converted to upper case and 478 vice versa. 479 480 481 """ 482 pass
28 def swap_substr(s, one, other): 29 s = s.replace(one, "$$SUBSTR1$$").replace(other, "$$SUBSTR2$$") 30 s = s.replace("$$SUBSTR1$$", other).replace("$$SUBSTR2$$", one) 31 return s
58 def test_swap_case(): 59 assert Chepy("SoMe TeXt").swap_case().o == "sOmE tExT"
15 def reverse_str(string): 16 rev_list=[] 17 new_list=list(string) 18 while new_list: 19 rev_list += new_list[-1] 20 new_list.pop() 21 return ''.join(rev_list)