#有四个数字:1、2、3、4,能组成多少个互不相同且无重复数字的三位数?各是多少?
 d=[]
 for a in range(1,5):
 for b in range(1,5):
 for c in range(1,5):
 if (a!=b) and (a!=c) and (c!=b):
 d.append([a,b,c])
 print (“总数量:”, len(d))
 print(d)
Python List append()方法
Python 列表 Python 列表
 描述
append() 方法用于在列表末尾添加新的对象。
 语法
append()方法语法:
list.append(obj)
参数
obj -- 添加到列表末尾的对象。
返回值
该方法无返回值,但是会修改原来的列表。
 实例
以下实例展示了 append()函数的使用方法:
#!/usr/bin/python
aList = [123, ‘xyz’, ‘zara’, ‘abc’];
 aList.append( 2009 );
 print "Updated List : ", aList;
以上实例输出结果如下:
Updated List : [123, ‘xyz’, ‘zara’, ‘abc’, 2009]
 运行
 