Skip to content

Commit 3845e3a

Browse files
authored
Update Day_20.md
1 parent bdf012a commit 3845e3a

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

Status/Day_20.md

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ print(li)
9797
```python
9898

9999
li = [12,24,35,70,88,120,155]
100-
li = [x for (i,x) in enumerate(li) if i%2!=0]
100+
li = [x for (i,x) in enumerate(li) if i%2 != 0 and i <= 6]
101101
print li
102102
```
103103

@@ -107,10 +107,19 @@ print li
107107

108108
```python
109109
li = [12,24,35,70,88,120,155]
110-
li = [li[i] for i in range(len(li)) if i%2 != 0]
110+
li = [li[i] for i in range(len(li)) if i%2 != 0 and i <= 6]
111111
print(li)
112112
```
113+
---
114+
```python
115+
'''Solution by: popomaticbubble
116+
'''
117+
orig_lst = [12,24,35,70,88,120,155]
118+
indices = [0, 2, 4, 6]
113119

120+
new_list = [i for (j, i) in enumerate(orig_lst) if j not in indices]
121+
print(new_list)
122+
```
114123
---
115124

116125
# Question 83
@@ -137,18 +146,23 @@ li = [x for (i,x) in enumerate(li) if i<3 or 4<i]
137146
print li
138147

139148
```
140-
141149
---
142-
143150
**My Solution: Python 3**
144151

145152
```python
146153
#to be written
147154
li = [12,24,35,70,88,120,155]
148-
li = [li[i] for i in range(len(li)) if i<3 or 4<i]
155+
li = [li[i] for i in range(len(li)) if i < 3 or i > 4]
149156
print(li)
150157
```
151-
158+
---
159+
```python
160+
'''Solution by: popomaticbubble
161+
'''
162+
orig_list = [12,24,35,70,88,120,155]
163+
new_list = [i for (j, i) in enumerate(orig_list) if j not in range(1,4)]
164+
print(new_list)
165+
```
152166
---
153167

154168
# Question 84

0 commit comments

Comments
 (0)