Python String Snippets

The Python snippet collection contains helper functions for Python 3.6. It includes utilities for most common data types, such as primitivies, lists, dictionaries and date objects.

  • 6 Python f-strings tips and tricks

    Python's f-strings can do a lot more than you might expect. Learn a few useful tips and tricks in this quick guide.

    Python, String · Jul 20, 2021

  • Hex to RGB

    Converts a hexadecimal color code to a tuple of integers corresponding to its RGB components.

    Python, String · Sep 15, 2020

  • String to words

    Converts a given string into a list of words.

    Python, String · Nov 2, 2020

  • Camelcase string

    Converts a string to camelcase.

    Python, String · Nov 2, 2020

  • Collection is empty

    Checks if the a value is an empty sequence or collection.

    Python, List · Jan 12, 2023

  • Integer to roman numeral

    Converts an integer to its roman numeral representation. Accepts value between 1 and 3999 (both inclusive).

    Python, Math · Nov 2, 2020

  • Tip: 2 ways to format a string in Python

    Learn two ways to format a string in Python with this quick tip.

    Python, String · Jun 12, 2021

  • Kebabcase string

    Converts a string to kebab case.

    Python, String · Nov 2, 2020

  • RGB to hex

    Converts the values of RGB components to a hexadecimal color code.

    Python, String · Nov 2, 2020

  • Longest item

    Takes any number of iterable objects or objects with a length property and returns the longest one.

    Python, List · Oct 17, 2021

  • Split into lines

    Splits a multiline string into a list of lines.

    Python, String · Nov 2, 2020

  • Snakecase string

    Converts a string to snake case.

    Python, String · Nov 2, 2020

  • Capitalize string

    Capitalizes the first letter of a string.

    Python, String · Nov 2, 2020

  • Decapitalize string

    Decapitalizes the first letter of a string.

    Python, String · Nov 2, 2020

  • String to slug

    Converts a string to a URL-friendly slug.

    Python, String · Oct 25, 2020