fruits = ["watermelon","banana","Cherry","pineapple","oranges"]
vegitable = ["Tomato","potato","torry","bottle goud","bittre gourd"]
#adding fruits and vegitable in a list called dirty_dozen
dirty_dozen = [fruits, vegitable]
print(dirty_dozen)
list_of_names=["Bill", "John", "Susan", "Bob", "Emma","Katherine"]
new_name="James"
list_of_names.append(new_name)
# The list is now ["Bill", "John", "Susan", "Bob", "Emma","Katherine", "James"]
list_1 = ['w','h']
list_1.append('y') # you need no veribal to store list_1.append('y')
print(list_1) # ['w','h','y']
list_2 = ['a','r','e']
list_1.append(list_2) # This also donot need a veribal to store it
print(list_1) # ['w','h','y',['a','r','e']]
list_1.extend(list_2)
print(list_1) # ['w','h','y',['a','r','e'],'a','r','e']
# please like
def main():
number_of_values = int(input('Please enter number of values: ')) # int
myList = create_list(number_of_values) # myList = function result
total = get_total(myList)
print('the list is: ', myList)
print('the total is ', total)
def get_total(value_list):
total = 0
for num in value_list:
total += num
return total
def create_list(number_of_values):
myList = []
for _ in range(number_of_values): # no need to use num in loop here
num = int(input('Please enter number: ')) # int
myList.append(num)
return myList
if __name__ == '__main__': # it's better to add this line as suggested
main()
list_1 = ['w','h']
list_1.append('y') # you need no veribal to store list_1.append('y')
print(list_1) # ['w','h','y']
list_2 = ['a','r','e']
list_1.append(list_2) # This also donot need a veribal to store it
print(list_1) # ['w','h','y',['a','r','e']]
list_1.extend(list_2)
print(list_1) # ['w','h','y',['a','r','e'],'a','r','e']