PYTHON

Create a list in Python to perform calculation

n=int(input("Enter number of elements: ")) lst = [] for i in range(n): value = int(input(f"Enter element {i+1}: ")) lst.append(value) print("Dynamic List:", lst) #printing the length of the list print("Length of list is:", len(lst)) #Print the elements from second to fourth position using positive indexing print("2nd to 4th Position elements:",lst[1:4]) #Print the elements from position third to fifth using negative indexing print("Print the elements from position third to fifth using negative indexing",lst[-4:-1])

OUTPUT…..

Leave a Reply

Your email address will not be published. Required fields are marked *

sign up!

We’ll send you the hottest deals straight to your inbox so you’re always in on the best-kept software secrets.