How to Reverse Words or Sentences in Python
Let’s take the following sentence:
words = "These are some words"
We can use slices to reverse the order of the string:
print( …
Read Article →
In-depth guides, insights, and best practices for modern software engineering
Let’s take the following sentence:
words = "These are some words"
We can use slices to reverse the order of the string:
print( …
Read Article →
If you get the following error while trying to install something via Homebrew
AttributeError: 'int' object has no attribute 'split' - make: *** …
By default, Docker pushes its images to Docker Hub.
While Docker Hub is a great way to share both your public and private images, you may find the …
Read Article →Welcome to our comprehensive guide on how to python base64 encode a string in Python. …
The random module allows you to generate choices.
import random
print(random.choices([i for i in range(1000)], k=10))
This might give us back …
Read Article →Return the middle character of the word. If the word’s length is odd, return the middle character. If the word’s length is …
Read Article →If you have a string and want to create a Datetime object out of it in Python, then you can use the Datetime Parse Time method, as follows:
from …
Read Article →
Sometimes you don’t want a SELECT query to run for more than a set amount of time.
This is a roundabout way to make your server doesn’t …
Read Article →Python ships with a multiprocessing module that allows your code to run functions in parallel by offloading calls to available processors.
In this …
Read Article →Given a string, you have to return a string in which each character (case-sensitive) is repeated once.
double_char("String") …
Read Article →
Complete the function that accepts a string parameter, and reverses each word in the string. All spaces in the string should be …
Read Article →Create a function with two arguments that will return an array of the first (n) multiples of (x).
Assume both the given number and the …
Read Article →Given a list of integers and a single sum value, return the first two values (parse from the left please) in order of appearance that …
Read Article →If you have a large list and want to create smaller lists of it, with a maximum amount of elements, then:
commands = [str(i) for i in range(100)] …
Read Article →
If you want to print out a list of all dates between 2 dates (a date range), then you can use the following script:
from datetime import date, …
Read Article →
If you want to append a Python dictionary to a Pandas DataFrame, you can do this:
# Create a new DataFrame
output = pd.DataFrame()
# Append the …
Read Article →
You can store secrets in AWS Secret Manager and reference their ARN in AWS Systems Secret Manager.
The below snippet allows you to specify the …
Read Article →Implement a function that adds two numbers together and returns their sum in binary. The conversion can be done before or after the …
Read Article →You have successfully written your pandas Dataframe to an Excel file, but when you open it, all the columns are squashed up against each other.
There …
Read Article →You will be given an array of numbers. You have to sort the odd numbers in ascending order while leaving the even numbers at their …
Read Article →Create a function that returns the sum of the two lowest positive numbers given an array of minimum 4 positive integers. No floats or …
Read Article →Implement the function unique_in_order which takes as argument a sequence and returns a list of items without any elements with the same …
On Linux, you can change the hostname by using the hostnamectl command.
You’ll typically need to do this right after provisioning a new server, …
Read Article →Once you have a Docker container, it is really simple to deploy containers to Kubernetes.
kubectl provides a fantastic way …