Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vool/baff6365ce81a9be71a2291bacd1184f to your computer and use it in GitHub Desktop.
Save vool/baff6365ce81a9be71a2291bacd1184f to your computer and use it in GitHub Desktop.
The lowest whole number without a wikipedia (en) entry
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import urllib.request, urllib.error\n",
"from itertools import count"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"baseurl = \"https://en.wikipedia.org/wiki/\""
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"404 - https://en.wikipedia.org/wiki/2553\n"
]
}
],
"source": [
"for i in count(0):\n",
" req = urllib.request.Request(baseurl+str(i))\n",
" try:\n",
" urllib.request.urlopen(req)\n",
" except urllib.error.HTTPError as e:\n",
" print(str(e.code)+\" - \"+baseurl+str(i) )\n",
" break"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment