s = set(['Adam', 'Lisa', 'Paul'])
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for x in L:
if x in s:
s.remove(x)
else:
s.add(x)
print s
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for x in L:
if x in s:
s.remove(x)
else:
s.add(x)
print s
2016-01-18
s = set([('Adam', 95), ('Lisa', 85), ('Bart', 59)])
for x in s:
print x[0],':',x[1]
for x in s:
print x[0],':',x[1]
2016-01-18
months = set(['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'])
x1 = 'Feb'
x2 = 'Sun'
if x1 in months:
print 'x1: ok'
else:
print 'x1: error'
if x2 in months:
print 'x2: ok'
else:
print 'x2: error'
x1 = 'Feb'
x2 = 'Sun'
if x1 in months:
print 'x1: ok'
else:
print 'x1: error'
if x2 in months:
print 'x2: ok'
else:
print 'x2: error'
2016-01-18
上一次是ur'''.....'''弄成r'''...'''的错误,这次是倒叙索引越界的错误。
2016-01-18
print 'hello,python'
print 'hello'+'python'
print 'hello'+'python'
2016-01-18
-.-!坑爹的参考代码。谁让你做加法运算了。
for x in [1,2,3,4,5,6,7,8]:
for y in [2,3,4,5,6,7,8,9]:
if x < y :
print (x,y)
for x in [1,2,3,4,5,6,7,8]:
for y in [2,3,4,5,6,7,8,9]:
if x < y :
print (x,y)
2016-01-18