fosstodon.org is one of the many independent Mastodon servers you can use to participate in the fediverse.
Fosstodon is an invite only Mastodon instance that is open to those who are interested in technology; particularly free & open source software. If you wish to join, contact us for an invite.

Administered by:

Server stats:

10K
active users

Bob Belderbos

So many nuances with string methods :)

The str.replace() method takes an optional count argument so you for example can only replace the first match:

>>> s = "hello world, hello again"
>>> s.replace("hello", "bye")
'bye world, bye again'
>>> s.replace("hello", "bye", 1)
'bye world, hello again'