Tag: slice

  • How does slice work in Python

    Python, being a versatile and powerful programming language, provides several built-in functions and features to manipulate data efficiently. One such feature is the slice operation, which allows you to extract a portion of a sequence, such as a string, list, or tuple. Slicing provides a convenient way to access elements based on their indices and extract subsets of data as needed. In this article, we will explore how the slice operation works in Python and its various use cases.
    (more…)

  • Passing/reading command line arguments with Node.js

    It’s quite common when running an application to want to pass arguments to the program to define how it should run when executed. This is no different then with Node.js. To accomplish this I like to use one of two ways:

    1. Reading the JavaScript array node js process.argv and manually parsing the variables
    2. Using an npm library such as minimist that helps simplify and (in my opinion) parses them into a nice JavaScript variable

    Let’s take a look at both ways.

    (more…)

  • Zero Padding a Number with JavaScript

    This morning I had to format a date using JavaScript as follows: yyyymmdd requiring both the month and day to include a leading zero when the month or day was less than 10. This solution using slice multiple times.

    (more…)