print [int(str(a)+str(b)+str(a)) for a in range(1,10) for b in range(10) ]
2015-01-26
L = [95.5, 85, 59]
print 'Bart9[-1],'
print 'Lisa[-2],'
print 'Adam[-3],'
print 'list index out of range'
为什么不可以呢??请问我哪里错了
print 'Bart9[-1],'
print 'Lisa[-2],'
print 'Adam[-3],'
print 'list index out of range'
为什么不可以呢??请问我哪里错了
2015-01-25
这样写也可以:
print [str(x)+str(y)+str(z) for x in range(1, 10) for y in range(10) for z in range(1, 10) if x == z]
print [str(x)+str(y)+str(z) for x in range(1, 10) for y in range(10) for z in range(1, 10) if x == z]
2015-01-25
分享一下我的代码:
print [int(a+b+a) for a in '123456789' for b in '0123456789']
print [int(a+b+a) for a in '123456789' for b in '0123456789']
2015-01-25
d = {
95: 'Adam',
85: 'Lisa',
59: 'Bart',
}
print d.get(95)
print d.get(85)
print d.get(59)
95: 'Adam',
85: 'Lisa',
59: 'Bart',
}
print d.get(95)
print d.get(85)
print d.get(59)
2015-01-24
sum = 0
x = 0.0
while True:
x = x + 1
if x > 100:
break
if x % 2 == 0:
continue
sum = sum + x
print sum
x = 0.0
while True:
x = x + 1
if x > 100:
break
if x % 2 == 0:
continue
sum = sum + x
print sum
2015-01-23
最新回答 / azhuan
set中的名字改一改结果就不一样了s = set(['Adam', 'Lisa', 'Saul'])L = ['Adam', 'Lisa', 'Bart', 'Paul']for name in L: if name in s: s.remove(name) else: s.add(name)print ss = set(['Adam', 'Lisa', 'Saul'])L = ['Adam', 'Lisa', 'Bart', 'Paul']s = set(L) -...
2015-01-23