Using lists

5.23. Using lists#

data = []
print(data)
[]
data.append("AA")
print(data)
['AA']
data.append("TTTT")
print(data)
['AA', 'TTTT']
len(data)  # to find out what len does, do help(len)
2

5.23.1. Lists within lists#

One feature of lists (and some other Python data types), is the ability to create objects that have multiple dimensions.

For instance, you can have a list whose elements are also lists.

Note

If creating a list of multiple elements from scratch, you must separate the elements using ",".

seq_records = []
seq_records.append(["label 1", "AA"])
print(seq_records)
[['label 1', 'AA']]
seq_records.append(["label 2", "TT"])
print(seq_records)
[['label 1', 'AA'], ['label 2', 'TT']]