Skip to content

Commit

Permalink
Merge pull request #8 from ilonabudapesti/master
Browse files Browse the repository at this point in the history
add str.maketrans() solution
  • Loading branch information
ilonabudapesti authored Jun 28, 2018
2 parents c51fa83 + dd4097a commit c8fb9d5
Showing 1 changed file with 45 additions and 2 deletions.
47 changes: 45 additions & 2 deletions toy-problems/toy-problem-003.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 3,
"metadata": {
"collapsed": false
},
Expand All @@ -296,7 +296,7 @@
"\"i hope you didnt translate it by hand. thats what computers are for. doing it in by hand is inefficient and that's why this text is so long. using string.maketrans() is recommended. now apply on the url.\""
]
},
"execution_count": 17,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -369,6 +369,49 @@
"\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"\"i hope you didnt translate it by hand. thats what computers are for. doing it in by hand is inefficient and that's why this text is so long. using string.maketrans() is recommended. now apply on the url.\""
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# solution with a built-in function str.maketrans()\n",
"\n",
"table = str.maketrans(\"abcdefghijklmnopqrstuvwxyz\", \"cdefghijklmnopqrstuvwxyzab\")\n",
"raw.translate(table)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
Expand Down

0 comments on commit c8fb9d5

Please sign in to comment.