1
+ #start- 7:20:00
2
+ #ends-8:03:00
3
+ #working with lists
4
+ #follow this syntax. you can store a number of data types in lists.
5
+
6
+
7
+
8
+ #guests=['Satya', 'Bill', 'Marsha']
9
+ #print(guests)
10
+ ##getting values in the list is done by indexing e.g. print(guest[-1])- couting backwards.
11
+ #print(guests[-1])
12
+ ##print(guests[0])- counting from the start
13
+ #print(guests[0])
14
+ ##append- adding a value to a list
15
+ #guests.append('Charles')
16
+ #print(guests)
17
+ ##remove- removing a value from the list-
18
+ ##it removes the first value if one value occurs multiple times
19
+ #guests.remove('Bill')
20
+ #print(guests)
21
+ ##del- deletes a value from the list
22
+ #del guests[2]
23
+ #print(guests)
24
+ ##insert- inserting a value into the list
25
+ #guests.insert(1, 'Tommy')
26
+ #print(guests)
27
+ ##update a value in the list
28
+ #guests[1]='Derreck'
29
+ #print(guests)
30
+ ##searching a list
31
+ #print(guests.index('Marsha'))
32
+
33
+ ##loops with lists
34
+ ##use the len() function to get the size of an array/list
35
+ #current_guests= len(guests)
36
+ #for people in range(current_guests):
37
+ # print(people)
38
+
39
+ ##you can also use the for loop; e.g. for guests in guests:
40
+ #for people in guests:
41
+ # print(people)
42
+
43
+ ##sorting through a lists
44
+ #guests.sort( )
45
+
46
+ #challenge
47
+ #the party challenge
48
+
49
+ guestList = ['' ]
50
+ coming = ''
51
+ main_guest = ''
52
+ plus_one = ''
53
+ people_bring = ''
54
+ counter = 0
55
+
56
+ print ('Are you coming to the party on saturday night? (yes/no)' )
57
+ coming = input ('' ).capitalize ()
58
+ if coming == 'Yes' :
59
+ print ('what is your name?' )
60
+ main_guest = input ('' )
61
+ guestList .append (main_guest )
62
+ print ('How many people do you want to bring? (please use digits e.g. 1,2,3)' )
63
+ people_bring = input ('' )
64
+ people_bring = int (people_bring )
65
+
66
+ while counter < people_bring :
67
+ print ('kindly tell us their name/s' )
68
+ plus_one = input ('' )
69
+ guestList .append (plus_one )
70
+ counter += 1
71
+
72
+ for guests in guestList :
73
+ sorted (guests )
74
+ print (guests )
75
+
76
+ sorted (guests )
77
+ print ('See you on Saturday night lol!! ;-)' )
78
+ else :
79
+ print ('You\' re gonna miss out on Saturday night.' )
80
+ print ('Try again if you change your mind, and bring someone if you can' )
81
+ print ('Everybody is invited' )
82
+
83
+ print ('Good day' )
84
+
85
+ #slicing a list
86
+ mylist = [0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ]
87
+ mylist [4 :8 ]
0 commit comments