Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

When I run this code in Python # Get our list from the command line import sys numbers = sys.argv[1].split(,) # Your code goes here

When I run this code in Python

# Get our list from the command line

import sys

numbers = sys.argv[1].split(",")

# Your code goes here

def sum(numbers):

total = 0

for x in numbers:

total+=x

return total

print(sum(numbers))

I get an error that says:

Program Output Traceback (most recent call last): File "sum.py", line 13, in print(sum(numbers)) File "sum.py", line 10, in sum total+=x TypeError: unsupported operand type(s) for +=: 'int' and 'str' 

I don't know what the error is saying. How can I fix this?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Programming questions