Skip to content

Explanation for max on strings #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: gh-pages
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions python/jupyter/01 Your first program in Python.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,66 @@
"max('codebar','is','great')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You weren't expected this result? On `string` the default order is the alphabetical order like in a normal dictionnary. In the alphabetical order `'codebar'` is before `'great'` which is before `'is'`. That's why `'is'` is the *bigger* one.\n",
"Play with the following examples to see how uppercase letter and special characters are ordered."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"max('space','space ')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"max('dot','dot.')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"max('dot and space ','dot and space.')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"max('U','u')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"max('o','ö')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The thing to remember here is that there `string` can be ordered. "
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down