2014-01-31 01:17:30 -05:00
|
|
|
print("".replace("a", "b"))
|
2015-03-14 17:20:58 -04:00
|
|
|
print("aaa".replace("b", "c"))
|
2014-01-31 01:17:30 -05:00
|
|
|
print("aaa".replace("a", "b", 0))
|
|
|
|
print("aaa".replace("a", "b", -5))
|
|
|
|
print("asdfasdf".replace("a", "b"))
|
|
|
|
print("aabbaabbaabbaa".replace("aa", "cc", 3))
|
|
|
|
print("a".replace("aa", "bb"))
|
|
|
|
print("testingtesting".replace("ing", ""))
|
|
|
|
print("testINGtesting".replace("ing", "ING!"))
|
2014-04-06 19:39:13 -04:00
|
|
|
|
|
|
|
print("".replace("", "1"))
|
|
|
|
print("A".replace("", "1"))
|
|
|
|
print("AB".replace("", "1"))
|
|
|
|
print("AB".replace("", "12"))
|
2015-08-21 06:56:14 -04:00
|
|
|
|
|
|
|
try:
|
|
|
|
'abc'.replace(1, 2)
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|
|
|
|
|
|
|
|
try:
|
|
|
|
'abc'.replace('1', 2)
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|