-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path57_lists.py
More file actions
53 lines (43 loc) · 1.06 KB
/
Copy path57_lists.py
File metadata and controls
53 lines (43 loc) · 1.06 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
# Lists in Python. Array in PHP.
# Normal Lists
names = ["Tom", "Dick", "Harry"]
print names
print "\n"
# Multiple Lists
people = ["Kiwi", ["Nanu", "Nani"], "Mama"]
print people
print "\n"
# Using FOR Loop 1
countdown = [10,9,8,7,6,5,4,3,2,1,0]
for time in countdown:
print time
print "Lift off!"
print "\n"
# Using FOR Loop 2
for friend in names:
print "Hello", friend
print "Welcome Aboard!"
print "\n"
# Lists - Index value
print people[1]
print "\n"
# Changing the Lists x-index value
print "Before Changing :", people
people[0] = "Kiwi Dakri"
print "After Changing :", people
print "\n"
# Number of Elements in lists
print "Number of elements for lists countdown is : ", len(countdown)
print "\n"
# range() function applied in lists
# Below code will print lists starting from 0 till 6 like : [0, 1, 2, 3, 4, 5, 6,]
print range(7)
print "\n"
# Using len() function inside range() function
print range(len(people))
print "\n"
# range() function using FOR loop
for i in range(len(names)):
friend = names[i]
print "Hello", friend
print "Welcome Aboard!\n"