-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist.py
More file actions
40 lines (29 loc) · 832 Bytes
/
list.py
File metadata and controls
40 lines (29 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#day 22
#list"list is collection of ordered elements
#list is changeble
marks=[3,5,6,"pratik",True]
# print(marks[0])
# print(marks[1])
# print(marks[2])
# print(marks[3])
#in list index start with 0 index
# print(marks[-3])#NEGATIVE
# print(marks[len(marks)-3])#POSITIVE INDEX
# print(marks[5-3])#POSITIVE INDEX
# print(marks[2])#POSITIVE INDEX
# if 7 in marks:
# print("yes")
# else:
# print("no")
#same thing apply for string as well
#if "pr" in pratik:
# print("yes")
# print(marks)
# print(marks[:])#to print all element
# print(marks[1:4:2]) #jump indedx
#list comprehension
#list comprehensions are used for creating new lists from other iterable like list ,tuple,dictionaries,sets
lst=[i*i for i in range(4)]
print(lst)
lst=[i**2 for i in range(11)]
print(lst)