You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
591 B
24 lines
591 B
print("".replace("a", "b"))
|
|
print("aaa".replace("b", "c"))
|
|
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!"))
|
|
|
|
print("".replace("", "1"))
|
|
print("A".replace("", "1"))
|
|
print("AB".replace("", "1"))
|
|
print("AB".replace("", "12"))
|
|
|
|
try:
|
|
'abc'.replace(1, 2)
|
|
except TypeError:
|
|
print('TypeError')
|
|
|
|
try:
|
|
'abc'.replace('1', 2)
|
|
except TypeError:
|
|
print('TypeError')
|
|
|