s = set(['Adam', 'Lisa', 'Bart', 'Paul'])
print s
s = { 'Adam', 'Lisa', 'Bart', 'Paul'}
print s
两种方式皆可。
print s
s = { 'Adam', 'Lisa', 'Bart', 'Paul'}
print s
两种方式皆可。
2018-11-05
s=set(['Adam', 'Lisa', 'Bart'])
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
我作弊了,我是看了答案才会的。
2018-11-04
s=set([('Adam, 95'), ('Lisa, 85'), ('Bart, 59')])
for x in s:
print x
for x in s:
print x
2018-11-04
d={ 'adam' : 95, 'lisa':85, 'bart' : 59}
for key in d:
name = key
score = d [key]
print name, score
for key in d:
name = key
score = d [key]
print name, score
2018-11-03
d={ 'adam' : 95, 'lisa':85, 'bart':58}
print 'adam', ':', d['adam']
print 'lisa', ':', d['lisa']
print 'bart', ':', d['bart']
print 'adam', ':', d['adam']
print 'lisa', ':', d['lisa']
print 'bart', ':', d['bart']
2018-11-03
for x in [1, 2, 3, 4, 5, 6, 7, 8, 9]:
for y in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]:
if x<y:
print x*10+y
for y in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]:
if x<y:
print x*10+y
2018-11-03