Hitungan penggantian maksimum dalam python

s = 'one two one two one'
print(s.replace('one', 'XXX'))
# Output -
# XXX two XXX two XXX

s = 'one two one two one'
print(s.replace('one', 'XXX', 2))
# 2 is the number of count
# Output -
# XXX two XXX two one
Rajitha Amarasinghe