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'
@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.
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:
#Python #Programming #Coding #LearnPython #LearnToCode #Offside #Football #soccer
• Rethinking how to teach programming – I prefer the friendly, relaxed approach when communicating about Python programming
• I write about Python on The Python Coding Book blog and on Real Python
• Former Physicist
• Expect posts on scientific and numerical programming –> NumPy, Matplotlib and friends!