Skip to content

Commit 0955776

Browse files
committed
enumerate is added
1 parent dfac5a3 commit 0955776

File tree

4 files changed

+64
-58
lines changed

4 files changed

+64
-58
lines changed

.ipynb_checkpoints/Django-checkpoint.ipynb

Lines changed: 0 additions & 6 deletions
This file was deleted.

Django.ipynb

Lines changed: 0 additions & 52 deletions
This file was deleted.

Python-1.ipynb

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,6 +1172,69 @@
11721172
"print(x)"
11731173
]
11741174
},
1175+
{
1176+
"cell_type": "markdown",
1177+
"metadata": {},
1178+
"source": [
1179+
"## Enumerate"
1180+
]
1181+
},
1182+
{
1183+
"cell_type": "code",
1184+
"execution_count": 10,
1185+
"metadata": {},
1186+
"outputs": [
1187+
{
1188+
"name": "stdout",
1189+
"output_type": "stream",
1190+
"text": [
1191+
"type : <enumerate object at 0x000002B6FBAB1C60>\n",
1192+
"[(0, 'sam'), (1, 'bob'), (2, 'mike')]\n",
1193+
"[(2, 'sam'), (3, 'bob'), (4, 'mike')]\n"
1194+
]
1195+
}
1196+
],
1197+
"source": [
1198+
"string1 = [\"sam\",\"bob\",\"mike\"]\n",
1199+
"string2 = 'python'\n",
1200+
"\n",
1201+
"obj1 = enumerate(string1)\n",
1202+
"obj2 = enumerate(string2)\n",
1203+
"\n",
1204+
"print(\"type : {}\".format(obj1))\n",
1205+
"\n",
1206+
"# return a position with string\n",
1207+
"print(list(enumerate(string1)))\n",
1208+
"\n",
1209+
"# return a position which is start from 2 \n",
1210+
"print(list(enumerate(string1,2)))\n",
1211+
"\n"
1212+
]
1213+
},
1214+
{
1215+
"cell_type": "code",
1216+
"execution_count": 12,
1217+
"metadata": {},
1218+
"outputs": [
1219+
{
1220+
"name": "stdout",
1221+
"output_type": "stream",
1222+
"text": [
1223+
"bucky you are in position 0\n",
1224+
"Mike you are in position 1\n",
1225+
"Dustin you are in position 2\n"
1226+
]
1227+
}
1228+
],
1229+
"source": [
1230+
"import numpy as np\n",
1231+
"\n",
1232+
"name = np.array(['bucky','Mike','Dustin'])\n",
1233+
"\n",
1234+
"for i,c in enumerate(name):\n",
1235+
" print(\"{} you are in position {}\".format(c,i))"
1236+
]
1237+
},
11751238
{
11761239
"cell_type": "markdown",
11771240
"metadata": {},

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- [lambda](#image)
1717
- [filter](#image)
1818
- [Unpacking](#GIF)
19+
- [Enumerate](#GIF)
1920
- [Dictionaries](#code-blocks)
2021
- [Function](#tables)
2122
- [Parameter and Arguments](#task-list)

0 commit comments

Comments
 (0)