DEV Community

Henrique Lopes
Henrique Lopes

Posted on

How do I improve my python skills

I'll give you a simple tip about improving your python skills. It’s very simple and of the bonus is that many technology companies apply your challenges over there. I'm speaking about Hackerrank which is a famous platform where you can practice coding and find jobs . I usually take up one coding challenge per week, I like math problems and Python.

You can find range of problems over there, it starts from basic to the most difficult ones, at every step you get a different level problem . I use this tool to think better and to practise. My profile contact is contato44. I'll share a simple problem that you can to see on Hackerrank:

    >>> count_substring("ABCDCDC", "CDC")
    >>> count_substring("ABCDCDCAAAACDC", "CDC")
    >>> count_substring("ThIsisCoNfUsInG", "is")

def count_substring(string, sub_string):
    occurrences = 0

    for i, __ in enumerate(string):
        cut = string[i:len(sub_string)+i]
        if cut == sub_string:
            occurrences += 1
    return occurrences

To solve the problem I'm using the Doctest, because is it simple and fast to write the test. I submit the solution with Doctest. You can execute the Doctest of 2 modes in your machine:

First mode:

PS: After to execute the code, add the snippet in final code.

if __name__ == "__main__":
   import doctest

Run the test feature.

$ python

Seconde mode:

ps: When I use the Doctest to run my test feature, this what I do.

$ python -m doctest

Today I share a simple tip on improving your developer skill, If have another tip, kindly let me know.

Originally post on:

Top comments (0)