lst = [ ] n = int(input("Enter number of elements : ")) for i in range(0, n): ele = input() lst.append(ele) print(lst) # this will add a specified amount of strings to the list (lst)
Here is what the above code is Doing:
1. We create an empty list.
2. We ask the user to input the number of elements they want to add to the list.
3. We use a for loop to add the specified number of elements to the list.
4. We print the list.