#!/usr/bin/python3
#=====================================================================================
# Python list (A list is an array in most languages)
#=====================================================================================
print("Content-Type: text/html \n")     #http header with newline char (required for web)

print('''
    <html>
    <body>
    <h1>Python Lists</h1>
''')

stuff1 = []                                                 #create an empty list
stuff2 = [1,2,3,4,5,6,7,8,9]
stuff3 = ['Sam','John','Steve', 1, 2, 3]                    #list elements can be multiple data types


print('<b><u>Stuff1</u></b><br>')
print('Printing empty stuff1 list \t:', stuff1, '<br>')
print('<br>')

print('<b><u>Stuff2</u></b><br>')
print('Printing the entire stuff2 list .......... \t:', stuff2,                      '<br>')
print('Printing the first 2 elements of stuff2    \t:', stuff2[0], 'and', stuff2[1], '<br>')
print('Printing the first 2 elements of stuff2    \t:', stuff2[0:2],                 '<br>')
print('Printing the number of elements in stuff2  \t:', len(stuff2),                 '<br>')
print('<br>')

print('<b><u>Stuff3</u></b><br>')
print('Printing the entire stuff3 list \t:', stuff3, '<br>')
stuff3[0] = 'Samuel'                                                #change value of element
stuff3.append(4)                                                    #add new element to end of list
stuff3.append('Bill')                                               #add another element to end of list
stuff3.insert(3,'Jack')                                             #insert a new element at index 3
del stuff3[2]                                                       #delete 3rd element
print('After add, change and delete .. \t:', stuff3, '<br>')
print('<br>')

print(''' 
    </body> 
    </html> 
''')      



#=== link to see the python code =================================================
import os, sys
sys.path.insert(0,'/home/s/sultans/web/python/demo')
import zCode                          #import func to display the Python code
filename = os.path.abspath(__file__)  #get absolute file name 
zCode.display(filename)               #call it
#=================================================================================