myList = []
numbers = int(input("How many numbers would you like to enter? "))
for numbers in range(1,numbers + 1):
x = int(input("Please enter number %i: " %(numbers)))
myList.append(x)
b = sum(x for x in myList if x < 0)
for x in myList:
print("Sum of negatives = %r" %(b))
break
c = sum(x for x in myList if x > 0)
for x in myList:
print("Sum of positives = %r" %(c))
break
d = sum(myList)
for x in myList:
print("Sum of all numbers = %r" %(d))
break
我需要弄清楚如何詢問用戶是否想再次使用該程序。我還沒有學過功能,每次我嘗試將整個程序放入「while True:」循環時,它只會重複「您想輸入多少個數字?」任何幫助表示讚賞,我對python沒有經驗,這令人沮喪!需要問用戶是否要重複使用for循環(Python)