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.

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

  • Hex to RGB

    Python, String

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

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

  • RGB to hex

    Python, String

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

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

  • String to words

    Python, String

    Converts a given string into a list of words.

  • Kebabcase string

    Python, String

    Converts a string to kebab case.

  • Longest item

    Python, List

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

  • Split into lines

    Python, String

    Splits a multiline string into a list of lines.

  • Camelcase string

    Python, String

    Converts a string to camelcase.

  • Snakecase string

    Python, String

    Converts a string to snake case.

  • Learn of the two different way to convert a string to lowercase in Python and understand when you should use each one with this quick guide.

  • Capitalize string

    Python, String

    Capitalizes the first letter of a string.

  • Decapitalize string

    Python, String

    Decapitalizes the first letter of a string.

  • String is anagram

    Python, String

    Checks if a string is an anagram of another string (case-insensitive, ignores spaces, punctuation and special characters).