我想在用戶輸入列表中添加所有的負整數,但函數始終返回0作爲答案。如果我將該列表作爲函數的一部分包含在內,但它在用戶輸入時不起作用。我有的代碼是: def sumNegativeInts(userList):
userList = []
sum = 0
for i in userList:
if i < 0:
sum = sum + i
我正在做一個python刻字任務。 90或以上是A等等等等等字母等級的其餘部分;但是當一個值輸入爲負數時,我需要代碼除了顯示error之外什麼也不做。 這是我試過到目前爲止: #Design a Python program to assign grade to 10 students
#For each student, the program first asks for the user
我試圖做一個保理程序,但它似乎不適用於負數a-,b-和c-輸入。 from fractions import gcd
factor = -1
opp = 0
number = 1
success = 0
a = int(input("a-value: "))
b = int(input("b-value: "))
c = int(input("c-value: "))
factor