In [10]:
li = [56,24,42,10]
In [11]:
type(54)
Out[11]:
int
In [12]:
type(li)
Out[12]:
list
In [13]:
mi = []
In [14]:
print(li[2])
42
In [15]:
li[2] = 99
In [16]:
print(li)
[56, 24, 99, 10]
In [17]:
li.insert(2,100)
In [18]:
print(li)
[56, 24, 100, 99, 10]
In [19]:
li.append(200)
In [20]:
print(li)
[56, 24, 100, 99, 10, 200]
In [21]:
li.pop(3)
Out[21]:
99
In [22]:
print(li)
[56, 24, 100, 10, 200]
In [23]:
li.append("Jonathan")
In [24]:
print(li)
[56, 24, 100, 10, 200, 'Jonathan']
In [25]:
mi.append(10)
mi.append(20)
In [26]:
print(mi)
[10, 20]
In [27]:
ni = li + mi
In [28]:
print(ni)
[56, 24, 100, 10, 200, 'Jonathan', 10, 20]
In [29]:
pi = ni[0:5]
In [30]:
print(pi)
[56, 24, 100, 10, 200]
In [31]:
name = ['J','o','n']
In [32]:
print(name)
['J', 'o', 'n']
In [33]:
myname = 'Raj'
In [34]:
myname.append('a')
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-34-5f5f84af7bd0> in <module>
----> 1 myname.append('a')

AttributeError: 'str' object has no attribute 'append'
In [ ]:
myname = myname + 'a'
In [ ]:
print(myname)
In [ ]:
myname[0:2]
In [ ]:
import csv
In [40]:
import csv

def read_building(fname):
    with open(fname) as f:
        data = csv.reader(f,delimiter=',')
        for row in data:
            print("insert into BUILDING values ('"+row[0].strip()+"','"+row[1].strip()+"');")

def main():
    read_building("building-codes.csv")

main()
starting main
opened file
<_csv.reader object at 0x1086b9cd0>
['25PP', '25 Park Place']
insert into BUILDING values ('25PP','25 Park Place');
['ADHOLD', 'Adherhold Learning Center']
insert into BUILDING values ('ADHOLD','Adherhold Learning Center');
['ARTS', 'Art & Humanities Bldg']
insert into BUILDING values ('ARTS','Art & Humanities Bldg');
['CLSO', 'Classroom South Bldg']
insert into BUILDING values ('CLSO','Classroom South Bldg');
['COE', 'College of Education']
insert into BUILDING values ('COE','College of Education');
['COMMON', 'University Commons']
insert into BUILDING values ('COMMON','University Commons');
['KELL', 'Kell Hall']
insert into BUILDING values ('KELL','Kell Hall');
['LANGDL', 'Langdale Hall']
insert into BUILDING values ('LANGDL','Langdale Hall');
['LIBSO', 'Library South']
insert into BUILDING values ('LIBSO','Library South');
['NSC', 'Natural Science Center']
insert into BUILDING values ('NSC','Natural Science Center');
['PIED', 'Piedmont Hall']
insert into BUILDING values ('PIED','Piedmont Hall');
['PSC', 'Petit Science Building']
insert into BUILDING values ('PSC','Petit Science Building');
['SPARKS', 'Sparks Hall']
insert into BUILDING values ('SPARKS','Sparks Hall');
['URBAN', 'Urban Life Bldg']
insert into BUILDING values ('URBAN','Urban Life Bldg');
In [ ]:

In [ ]: