You can append a list in for loop, Use the list append() method to append elements to a list while iterating over the given list.
Append list in a for loop
Python simple example code.
data = ["a", "b", "c", "d"]
results = []
print(results)
for x in data:
results.append(x)
print(results)
Output:
Do comment if you have any doubts and suggestions on this python list topic.
Note: IDE: PyCharm 2021.3.3 (Community Edition)
Windows 10
Python 3.10.1
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.
what is the purpose of using append in loop function???
Dynamic update