INTERMEDIATE LIST FUNCTION
#creating list
continent=["asia","europe","africa"]
print continent
#indexing a list
earth=continent[2]
print earth
#modifying a list
continent[2]='australia'
print continent
#appending a list
continent.append('america')
print continent
#deleting using pop
continent.pop(1)
#deleting using remove
continent.remove('america')
print continent
#deleting using del
del(continent[0])
print continent
#function review
girls=3
def caculation(x):
return x*4
print caculation(girls)
#multiple argument
liberia=['buchanan','greenville','robertsport','kakata','zwedra','monrovia']
print liberia
#placing list into function
def visit(k):
return k
print visit(liberia)
#printing one item from list in funx
def home(new_list):
return new_list[2]
print home(liberia)
#deleting in function
def mon(galaxy):
galaxy.pop(4)
return galaxy
print mon(liberia)
#adding in funx
def sun(light):
light.append('gbanga')
return light
print sun(liberia)
#counting in funx
count=[1,2,3,4,5,6,7,8,9,10]
def join_list(word,number):
return word+number
print join_list(liberia,count)
#loop list using for in funx
for i in count:
print i
for k in liberia:
print k
for i in count:
print i+1
#adding a new list in funx
streets=[[1,2,3,],[6,8,7,9]]
def shine(m):
result=sum(m,[])
print shine(streets)
No comments:
Post a Comment