Question: How do I fix this it keeps saying totnumbers += len(numValues) TypeError: object of type 'map' has no len() #getting file as input print (Enter

How do I fix this it keeps saying totnumbers += len(numValues) TypeError: object of type 'map' has no len()

#getting file as input

print ("Enter file name")

file1=input()

#try block

try:

error_to_catch=FileNotFoundError

#catching file not found exception

except NameError:

error_to_catch=IOError

#opening file

fName = open(file1)

#initialising variables

sVal, totnumbers = 0, 0

#loop statement for n values

for line_number, line in enumerate(fName):

numValues = map(int, line.split())

#calculating sum

sVal += sum(numValues)

totnumbers += len(numValues)

#printing results

print ("fileName",file1)

print ("sum",sVal)

print ("count:", totnumbers)

print ("Average:", 1.0*s/totnumbers)

#min max calculation

a=max(numValues)

b=min(numValues)

r=a-b

print ("maximum",a)

print ("minimum",b)

print ("Range",r)

value=input('would you like to continue:')

if value=='Y':

print ("Enter file name")

file1=input()

else:

print("good bye")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!