In [1]:
cities = ['NY', 'LA', 'SF']
In [2]:
city = cities[0]
In [3]:
city
Out[3]:
'NY'
In [5]:
for city in cities:
    if city == 'NY':
        print('Party')
    elif city == 'LA':
        print("It's hot here.")
    else:
        print('Where am I?')
Party
It's hot here.
Where am I?
In [6]:
t = (1,2,3)
In [7]:
t.append(2)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-7-14814bb52782> in <module>()
----> 1 t.append(2)

AttributeError: 'tuple' object has no attribute 'append'
In [8]:
my_list = [1,2,3]
In [10]:
my_dict = {'Taro':22, 'Yoko':12}
In [11]:
my_dict['Taro']
Out[11]:
22
In [12]:
len(my_dict)
Out[12]:
2
In [14]:
def adder(x,y):
    ''' これはxとyを足す関数です。'''
    answer = x+y
    return answer
In [15]:
adder(5,10)
Out[15]:
15
In [ ]: