cheeses = ["adam", "bree", "cheDDar", "GOUDA", "camambert"]
# change the names to Title case
for i in range(len(cheeses)):
cheeses[i] = cheeses[i].title()
print(cheeses)
i=0
for cheese in cheeses:
cheeses[i]= cheese.title()
i+=1
print(cheeses)
for i, cheese in enumerate(cheeses):
cheeses[i] = cheese.title()
print(cheeses)
list(enumerate(cheeses))
x= [1,2,3]
a=x[0]
b=x[1]
c=x[2]
print(a,b,c)
# unpacking
aa, bb, cc= x
print(aa, bb, cc)
# unpacking doesnt work with unbalanced left and right hand sides of '='
aa, bb, cc = [1,2,3,4]
x = 10
y = 100
# classic swap
z = x
x = y
y = z
# swap using unpacking
x,y = [y,x] # list
x,y = (y,x) # tuple
x,y = y,x # tuple
print(x,y)
(2+3)*4
print( (10, 20, 30) )
print( (10, 20) )
print( (10, ) )
x= 10,
print(x)
csv = """\
name, family, age, country
moshe, cohen, 20, israel
david, lev, 30, france
"""
lines= csv.splitlines()
print(lines)
header, *content = lines
#header, content= lines[0], lines[1:]
print(header)
print(content)
mosheline = content[0].split()
print(mosheline)
name, *eveything, country = mosheline
print(name, country, eveything)