In [1]:
s = "Hello World"
In [2]:
s.append("aaa")
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-2ab7add94dc3> in <module>
----> 1 s.append("aaa")

AttributeError: 'str' object has no attribute 'append'
In [3]:
t = s + "aaa"
In [4]:
print(t)
Hello Worldaaa
In [ ]:
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()
In [5]:
numbers = [10,20,15,40]
sum = 0
for x in numbers:
    sum = sum + x
print(sum)
85
In [6]:
numbers = [10,20,15,40]
product = 1
for x in numbers:
    product = product * x
print(product)
120000
In [7]:
def add_numbers(nums):
    sum = 0
    for x in nums:
        sum = sum + x
    return(sum)
In [8]:
print(add_numbers([1,2,3]))
6
In [9]:
print(add_numbers([10,40,90]))
140