Skip to content

Commit

Permalink
Add print end
Browse files Browse the repository at this point in the history
  • Loading branch information
baniasbaabe committed Jan 21, 2024
1 parent eb4fd52 commit 026f21e
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions book/pythontricks/Chapter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,36 @@
"point = Point(2,4)\n",
"point.z = 5 # Throws an error"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Modify Print Statements"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"When printing multiple elements in Python, it starts a new line by default.\n",
"\n",
"But, you can change this default to whatever you like by setting the `end` parameter in `print()`.\n",
"\n",
"See below where we change the `end` parameter to space."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"sports = [\"football\", \"basketball\", \"volleyball\", \"tennis\", \"handball\"]\n",
"\n",
"for sport in sports:\n",
" print(sport, end=\" \")"
]
}
],
"metadata": {
Expand Down

0 comments on commit 026f21e

Please sign in to comment.