Skip to content

Commit 2272632

Browse files
authored
Create 4 List[].py
1 parent e35cb80 commit 2272632

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

4 List[].py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# List[], Tuples(), Set{}
2+
# List = []
3+
names = ['maniraj', 'priya', 'rubi', 'maniraj']
4+
print(names)
5+
6+
#call particular value in list
7+
print(names[0])
8+
9+
#slicing
10+
print(names[0:2])
11+
12+
#negative slicing
13+
print(names[-4:-2])
14+
print(names[-4:-1])
15+
16+
17+
# change or update the list
18+
names[3] = 'subash'
19+
print(names)
20+
21+
# methods - append
22+
names.append('nivi')
23+
print(names)
24+
25+
26+
# methods - sort
27+
28+
#ascending
29+
no = [9, 6, 3, 5, 1]
30+
no.sort()
31+
print(no)
32+
33+
#decending
34+
no.sort(reverse=True)
35+
print(no)
36+
37+
#add two List[]
38+
addition = names + no
39+
print(addition)
40+
41+
# length
42+
print(len(names))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy