Software engineering and personal development

Month: May 2022

How to Use Methods that you have not Implemented yet in Python

aerial view of zigzag road on mountain
Photo by Johannes Hofmann on Unsplash

If you are implementing a new class, but do not have time now, or simply want to postpone it for later, then you can use the pass statement.

I have seen it being used all over the place, and I think it is a good idea to use it when you are writing a class that does not have any bodies of any methods, or when you are implementing a class that is not yet complete.

You can use it to do test-driven development when you initially write a failing test that calls a method that is not implemented yet, which you can then implement and fix the failing test.

Another scenario when I saw it being used was in coding assignments that are part of homework.

Continue reading

How to Quickly Check Whether a List Contains Duplicate Elements in Python

white and yellow daisy in bloom
Photo by Stefan Cosma on Unsplash

Sometimes, you may need to check whether a list has any duplicate elements. This can be a common task when you are given a list of numbers or a list of strings. This can also be something that you may need to do both at work, or it can also be part of a coding challenge that you are implementing when being asked at a programming interview.

Continue reading

How to Find the Index of a Substring in a string

file cabinet
Photo by Maksym Kaharlytskyi on Unsplash

Many programming interview questions have something to do with working with indexes. You may also be dealing with tasks at work that can have something to do with indexes.

One such task can be doing different splits and formattings of text files based on an index of a specific character.

Let us assume that you are asked to remove part of a string based on a certain index in a string.

Continue reading

© 2024 Fatos Morina

Theme by Anders NorenUp ↑