一下子出现
print [a*100+b*10+a for a in range(1,10) for b in range(0,10)]
print [a*100+b*10+a for a in range(1,10) for b in range(0,10)]
2018-09-19
我想问,这个有问题吧!
你的代码应该是跟我的代码一样的吧
L=[]
for a in range(1,10):
for b in range(0,10):
for a in range(1,10):
L.append(a*100+b*10+a)
print L
这样的结果是错误的,重复了很多遍!
[101, 202, 303, 404, 505, 606, 707, 808, 909, 111, 212, 313, 414, 515, 616, 717, 818, 919, 121, 222, 323, 424, 525, 626, 727, 828, 929, 131, 232, 333, 434, 535, 636, 737, 838, 939, 141, 242, 343, 444, 545, 646, 747, 848, 949, 151, 252, 353, 454, 555, 656, 757, 858, 959, 161, 262, 363, 464, 565, 666, 767, 868, 969, 171, 272, 373, 474, 575, 676, 777, 878, 979, 181, 282, 383, 484, 585, 686, 787, 888, 989, 191, 292, 393, 494, 595, 696, 797, 898, 999, 101, 202, 303, 404, 505, 606, 707, 808, 909, 111, 212, 313, 414, 515, 616, 717, 818, 919, 121, 222, 323, 424, 525, 626, 727, 828, 929, 131, 232, 333, 434, 535, 636, 737, 838, 939, 141, 242, 343, 444, 545, 646, 747, 848, 949, 151, 252, 353, 454, 555, 656, 757, 858, 959, 161, 262, 363, 464, 565, 666, 767, 868, 969, 171, 272, 373, 474, 575, 676, 777, 878, 979, 181, 282, 383, 484, 585, 686, 787, 888, 989, 191, 292, 393, 494, 595, 696, 797, 898, 999, 101, 202, 303, 404, 505, 606, 707, 808, 909, 111, 212, 313, 414, 515, 616, 717, 818, 919, 121, 222, 323, 424, 525, 626, 727, 828, 929, 131, 232, 333, 434, 535, 636, 737, 838, 939, 141, 242, 343, 444, 545, 646, 747, 848, 949, 151, 252, 353, 454, 555, 656, 757, 858, 959, 161, 262, 363, 464, 565, 666, 767, 868, 969, 171, 272, 373, 474, 575, 676, 777, 878, 979, 181, 282, 383, 484, 585, 686, 787, 888, 989, 191, 292, 393, 494, 595, 696, 797, 898, 999, 101, 202, 303, 404, 505, 606, 707, 808, 909, 111, 212, 313, 414, 515, 616, 717, 818, 919, 121, 222, 323, 424, 525, 626, 727, 828, 929, 131, 232, 333, 434, 535, 636, 737, 838, 939, 141, 242, 343, 444, 545, 646, 747, 848, 949, 151, 252, 353, 454, 555, 656, 757, 858, 959, 161, 262, 363, 464, 565, 666, 767, 868, 969, 171, 272, 373, 474, 575, 676, 777, 878, 979, 181, 282, 383, 484, 585, 686, 787, 888, 989, 191, 292, 393, 494, 595, 696, 797, 898, 999, 101, 202, 303, 404, 505, 606, 707, 808, 909, 111, 212, 313, 414, 515, 616, 717, 818, 919, 121, 222, 323, 424, 525, 626, 727, 828, 929, 131, 232, 333, 434, 535, 636, 737, 838, 939, 141, 242, 343, 444, 545, 646, 747, 848, 949, 151, 252, 353, 454, 555, 656, 757, 858, 959, 161, 262, 363, 464, 565, 666, 767, 868, 969, 171, 272, 373, 474, 575, 676, 777, 878, 979, 181, 282, 383, 484, 585, 686, 787, 888, 989, 191, 292, 393, 494, 595, 696, 797, 898, 999, 101, 202, 303, 404, 505, 606, 707, 808, 909, 111, 212, 313, 414, 515, 616, 717, 818, 919, 121, 222, 323, 424, 525, 626, 727, 828, 929, 131, 232, 333, 434, 535, 636, 737, 838, 939, 141, 242, 343, 444, 545, 646, 747, ...........不复制了
举报