Skip to content

Commit 1528efb

Browse files
authored
Update 06-Lists.md
1 parent 1dbcb88 commit 1528efb

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

python/06-Lists.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<h1 align="center"> Lists </h1>
22

33
## What are lists ?
4-
> List is a collection in python. In most languages, it is called Array. We often need 'list' in our programs. Imagine you are writing a program to store name of every student in a class of 50 .
4+
> List is a collection in python. In most languages, it is called an Array. We often need 'list' in our programs. Imagine you are writing a program to store the name of every student in a class of 50 .
55
66
> Elements in a list are stored in sequential order . Every element can be accessed by their index value .
77
@@ -24,23 +24,23 @@ player_scores = [ 78, 103, 200 , 57] # >>> Initialized list with Integers
2424
player_names = [ "Karan" , "Chirag" , "Jay" , "Raj" ] # Initialized list with strings
2525
```
2626

27-
> Unlike other programming languages , in python we can Initialized or store elements in a list which are of different datatypes . For example,
27+
> Unlike other programming languages , in python we can Initialize or store elements which are of different datatypes in the same list. For example,
2828
2929
```python
3030

3131
unknown_list = [ "google", "tensorflow", 73 , 37.5 ] # works :P
3232

33-
print("Number of elements : "len(unknown_list)) # >>> Number of elements : 4
33+
print("Number of elements :", len(unknown_list)) # >>> Number of elements : 4
3434

3535
```
3636

3737
### Adding elements to the list
3838

3939
> We can add elements to the list by using append & insert methods .
4040
41-
* Insert( index , element) - We use this method to add elements to a specific postion in a list .
41+
* Insert(index , element) - We use this method to add elements to a specific postion in a list .
4242

43-
* append( element ) - We use this method to add elements to the back( last postion ) of the list .
43+
* append(element) - We use this method to add elements to the back(last postion) of the list .
4444

4545
```python
4646
scores = [ 1, 2 , 3 , 4 , 5 ] # Initialized list with Integers
@@ -135,10 +135,10 @@ _output_
135135
scores = [25, 89 , 90 , 45 , 87 ]
136136

137137
current = 0
138-
end = len(score)
138+
end = len(scores)
139139

140140
while current < end:
141-
print(scores[start])
141+
print(scores[current])
142142
current +=1
143143

144144
```
@@ -226,6 +226,6 @@ print(name_length) # >>> [6, 4 ,6 ,6]
226226
# list of squares
227227

228228
squares = [i*i for i in range(1,5)]
229-
print(squares) # >>> [1, 4 ,9 , 16 , 25]
229+
print(squares) # >>> [1, 4 ,9 , 16]
230230

231231
```

0 commit comments

Comments
 (0)