Hello everyone I'm having trouble with this program in Python called sumList(nums). I already tried to program it, but I get the incorrect output. The program is suppose to get the summ of numbers entered into a list by the user. Mine does not return the sum just the first number in the list. Can someone look at my code and run it to see what is wrong, and then tell me how to fix it. I'm using python3.4.3. The help would be appreciated.
This defines the sumList function.
def sumList(nums):
ListTotal = 0
for i in nums:
ListTotal = ListTotal+i
return ListTotal
Get the input from the user
def main():
print("This is a program that gathers the sum of all numbers entered into the list.")
nums = input("Please enter different numbers separated by a comma: ")
nums = nums.split(',')
#The loop counts through number of enties by the user and turns them into a list.
ListEntry = 0
for i in nums:
nums[ListEntry] = int(i)
ListEntry = ListEntry+1
SumTotal = sumList(nums)
# provides the sum of the numbers in the list. This gives the user output.
print('\The sum of the numbers in the list is {}.' .format(SumTotal))
main()