Python – Split String After K-th Occurrence of Separator

Coding Challenge πŸ’¬ Question: Given a Python string. How to split the string after the k-th occurrence of the separator (string or character)? In other words: how to ignore the first (k-1) separator occurrences when splitting a string? Here are three examples: πŸ‘‰ Related Tutorial: Python Split String After Second Occurrence Solution You can split … Read more

How to Print a NumPy Array Without Scientific Notation in Python

Problem Formulation Β» Problem Statement: Given a NumPy array. How to print the NumPy array without scientific notation in Python? Note: Python represents very small or very huge floating-point numbers in their scientific form. Scientific notation represents the number in terms of powers of 10 to display very large or very small numbers. For example, … Read more

Python – Split String After Second Occurrence of Separator

Coding Challenge πŸ’¬ Question: Given a Python string. How to split the string after the second occurrence of the separator (string or character)? In other words: how to ignore the first separator occurrence when splitting a string? Here are three examples: ‘a-b-c-d-e-f-g-h’ and sep=’-‘ should be split to [‘a-b’, ‘c’, ‘d’, ‘e’, ‘f’, ‘g’, ‘h’] … Read more

TypeError Built-in Function or Method Not Subscriptable (Fixed)

Overview 🌞 Do you encounter this stupid error? TypeError: ‘builtin_function_or_method’ object is not subscriptable You’re not alone—thousands of coders like you experience this error in thousands of projects every month. This short tutorial will show you exactly why this error occurs, how to fix it, and how to never make the same mistake again. So, … Read more

How to Count the Number of Unique Values in a List in Python?

Problem Statement:Β Consider that you have been given a list in Python. How will you count the number of unique values in the list? Example: Let’s visualize the problem with the help of an example: Given:Β li = [‘a’, ‘a’, ‘b’, ‘c’, ‘b’, ‘d’, ‘d’, ‘a’]Output:Β The unique values in the given list are ‘a’, ‘b’, ‘c’, ‘d’. … Read more

The Art of Clean Code [Book Reviews]

On this page, I’ll collect selected reader feedback for my newest book πŸ“• “The Art of Clean Code” (Amazon, NoStarch). I’ll only share the feedback from readers who explicitly agreed to publish it here. πŸ‘‰ Want to Get Featured Here? Feel free to send in your feedback by replying to any of my emails. “Cannot … Read more

Getting Started With Thonny – The Optimal IDE for the Raspberry Pi Pico

So you’ve decided to learn about microcontrollers and programming electronics. That’s great! There is a whole world of fun and exciting things to do in this realm, but for some, it can be a bit overwhelming when first getting started. Fear not – the newest iteration of microcontrollers from the Raspberry Pi institute is here, … Read more

Python Plot Logarithmic Axes — Easy Bitcoin Example

Quick Answer: To print a logarithmic x-axis or y-axis (base 10) without a Matplotlib axis object use plt.xscale(‘log’) or plt.yscale(‘log’). To set different bases or switch back to a linear scale, use {“linear”, “log”, “symlog”, “logit”} or set the basex and basey arguments (e.g., plt.yscale(‘log’, basey=2) for log base 2). Next, we’ll have a look … Read more