python list fundamental
# A python list is a collection of strings or numbers that are stored linearly
# len() function - to check the length of a list
a = ['hi', 'there', '!'] # a list with 3 elements
len(a) ## 3
a[0] ## 'hi'
a[2] = 'ho' ## Change an existing element
a = ['hi', 'there', '!'] # a list with 3 elements
a.append('aa')
a.append('bb')
b = sorted(a) # ['aa', 'bb', 'hi', 'there']
List Loop
a = [1, 2, 3]
sum = 0
for num in a:
sum = sum + num # sum = 6
a = ['hi', 'there', 'ok']
result = ''
for i in range(len(a)):
# i will be 0, 1, 2 ... use a[i] to look at each element.
# Here we just accumulate the a[i] strings
result = result + a[i]