🔵 🔵 🔵


Primary

၊၊||၊|။

str.replace() ⚬|Documentation|1st|20251021000328-00-⌔

Built-in Types — Python 3 documentation#str.replace

str.replace(old, new,/, count=-1)

Return a copy of the string with all occurrences of substring old replaced by new. If count is given, only the first count occurrences are replaced. If count is not specified or -1, then all occurrences are replaced. For example:

>>> 'spam, spam, spam'.replace('spam', 'eggs')
'eggs, eggs, eggs'
>>> 'spam, spam, spam'.replace('spam', 'eggs', 1)
'eggs, spam, spam'

Changed in version 3.13: count is now supported as a keyword argument.

Printed 2026-06-28.

(echo:: @ )

Link to original

Secondary

• • •