Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please find the Error/Bug in this python code: And clearly TYPE what the Error/Bug is, Where it occurs And how to resolve this Error/Bug Dont

Please find the Error/Bug in this python code:

And clearly TYPE what the Error/Bug is, Where it occurs

And how to resolve this Error/Bug

Dont have the data file. I dont need you to resolve the error/bug, just need you to write out what the error/bug is or would be and the solution to resolve it; conceptually.

Please TYPE

# -*- coding: utf-8 -*- import os

path = "/Users/user1/data/baby_names/" myyear = input("Please provide the year to be searched:") babyname = input("Please provide the baby name to be searched:") babyname = babyname.capitalize()

baby_counts = count_babies(myyear, babyname)

print("There were {0} boys and {1} girls with that name in {2}".format( baby_counts[0], baby_counts[1], myyear))

def count_babies(year, baby):

file = "yob" + year + ".txt" bnames = []

if file not in os.listdir(path): print("These are not the files you are looking for, move along") return 0 else: f = open(path + file) f.readline() for each in f: fields = each.split(',') bnames.append(fields) f.close() print("Imported " + file)

mcount = 0 fcount = 0 for fields in bnames: if baby in fields[0]: if 'M' in fields[1]: mcount = int(fields[2]) else: fcount = int(fields[2])

return [mcount, fcount] image text in transcribed

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What is operatiing system?

Answered: 1 week ago