-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathappend in list using input
More file actions
41 lines (35 loc) · 1.79 KB
/
append in list using input
File metadata and controls
41 lines (35 loc) · 1.79 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
Original_List = ["Toufik", "Assia", "Brahim", "Youcef"]
print("This is The Original List : ", Original_List)
####################################################
# Using .append("...") to add element in the original list
New_List = input("Add Name to the list : ")
Original_List.append(New_List)
print("This is The New list", Original_List)
Result:
This is The Original List : ['Toufik', 'Assia', 'Brahim', 'Youcef']
Add Name to the list : chalouli
This is The New list ['Toufik', 'Assia', 'Brahim', 'Youcef', 'chalouli']
########################################################################################################
#Usin while loop
Original_List = ["Toufik", "Assia", "Brahim", "Youcef"]
print("This is The Original List : ", Original_List)
New_List = input("Add Name to the list : ")
Original_List.append(New_List) # Using .append("...") to add element in the original list
print("This is The New list", Original_List)
while (Original_List):
New_List = input("Add Name to the list : ")
Original_List.append(New_List)
print("This is The New list", Original_List)
########################################################################################################
I WANT TO APPEND THE LIST BUT NOT MORE THAN 11 ELEMENT
Original_List = ["Toufik", "Assia", "Brahim", "Youcef"]
print("This is The Original List : ", Original_List)
####################################################
# Using .append("...") to add element in the original list
New_List = input("Add Name to the list : ")
Original_List.append(New_List)
print("This is The New list", Original_List)
while (len(Original_List)<=10): # Using while "loop" to repeat operation and "len" to limit List elements
New_List = input("Add Name to the list : ")
Original_List.append(New_List)
print("This is The New list", Original_List)