Skip to content

Instantly share code, notes, and snippets.

@veretennikovalexey
Created July 3, 2022 11:27
Show Gist options
  • Save veretennikovalexey/67ceb4acfb522cf993661ec38eaf3c05 to your computer and use it in GitHub Desktop.
Save veretennikovalexey/67ceb4acfb522cf993661ec38eaf3c05 to your computer and use it in GitHub Desktop.
pprint.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "pprint.ipynb",
"provenance": [],
"authorship_tag": "ABX9TyN35hQbo4bn0oPzvfTRR5qG",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/veretennikovalexey/67ceb4acfb522cf993661ec38eaf3c05/pprint.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "7E4audXuyk_g",
"outputId": "d883d085-5a40-498f-c7ef-3caca7fc7bec"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"{' ': 2,\n",
" 'A': 3,\n",
" 'd': 1,\n",
" 'e': 3,\n",
" 'l': 1,\n",
" 'm': 1,\n",
" 'n': 1,\n",
" 'r': 2,\n",
" 't': 1,\n",
" 'x': 1,\n",
" 'y': 1}\n"
]
}
],
"source": [
"import pprint\n",
"message = 'Alex Andrey Artem'\n",
"count = {}\n",
"\n",
"for character in message :\n",
" count.setdefault( character, 0 )\n",
" count[ character ] = count[ character ] + 1\n",
"\n",
"pprint.pprint( count )"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment