How to create a dynamic list in Python. I am trying to prepare a Array where the value will be pushed dynamically into it (using a loop)
Python lists are dynamic if you what you are asking is that they resize whenever an element is appended to them.
A dynamic list combines the power and flexibility that a fragment would have with contribution capabilities. The dynamic list performs a query in the content server, displays the files that match that query, and allows contributors to modify those files, even add new ones.
Try this one:
Initialize with a variable x
and the append into this array x
inside a for loop
as below:
x = []
n = input("enter length")
for i in range(1, int(n)):
k=input("enter value")
x.append(k) # push your entered value
print x
You can append any value in the loop as x.append(value)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With