我試圖把正數的列表與相同值負數的列表在Python 3.3.3Python的 - 如何將列表中的所有號碼到他們的負同行
例如把[ 1,2,3]到[-1,-2,-3]
謝謝您的幫助
我有這樣的代碼:
xamount=int(input("How much of x is there"))
integeramount=int(input("How much of the integer is there"))
a=1
lista=[]
while(a<=integeramount):
if(integeramount%a==0):
lista.extend([a])
a=a+1
listb=lista
print(listb)
[ -x for x in listb]
print(listb)
這將打印兩個相同的名單時,我想一個是posi略去,一個爲負
做'數組listB = -x對於x在LISTA]'我在答覆建議。 – Anton 2014-09-26 17:33:42