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'

#python

@karenshancock if you want to use programming for mathematical and scientific applications, then Python is perfect because all the tools it has in that area, starting from modules such as NumPy (Numerical Python) and Matplotlib (plotting) and many others.

You can use typing.get_type_hints() (or __annotations__) to get the type annotations of an object.

#python

Do you know the offside rule? Here’s a step-by-step tutorial to write a Python Offside Rule Quiz using Object-Oriented Programming

I score 10 out of 10 all the time. How about you?

Great article for anyone:

  • who wants to learn object-oriented programming
  • who wants to learn the offside rule

thepythoncodingbook.com/2022/1

Show more
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.