0

I thought I had this one figured out, but check50 disagrees.

The specification suggests that the output needs to be formatted as "Harry James Potter, born 1980 or Luna Lovegood, born 1981." To match this formatting with roster.py, I utilized this code, which may not be the most elegant, but it did give me proper formatting in my terminal

code removed in keeping with course's policy on academic honesty 

The result in my terminal was:

~/pset7/houses/ $ python import.py characters.csv
~/pset7/houses/ $ python roster.py Gryffindor
Lavender Brown, born 1979
Colin Creevey, born 1981
Seamus Finnigan, born 1979
Hermione Jean Granger, born 1979
Neville Longbottom, born 1980
Parvati Patil, born 1979
Harry James Potter, born 1980
Dean Thomas, born 1980
Romilda Vane, born 1981
Ginevra Molly Weasley, born 1981
Ronald Bilius Weasley, born 1980

Looks right to me, but apparently not. Check50 states the expected outputs are:

[{'first': 'Harry', 'middle': 'James', 'last': 'Potter', 'house': 'Gryffindor', 'birth': 1980}]

and

[{'first': 'Luna', 'middle': None, 'last': 'Lovegood', 'house': 'Ravenclaw', 'birth': 1981}]

So I should be able to achieve that by just printing rows like so:

code removed in keeping with course's policy on academic honesty 

and, indeed, this prints the expected output from check50 in my terminal:

{'first': 'Lavender', 'middle': None, 'last': 'Brown', 'birth': 1979}
{'first': 'Colin', 'middle': None, 'last': 'Creevey', 'birth': 1981}
{'first': 'Seamus', 'middle': None, 'last': 'Finnigan', 'birth': 1979}
{'first': 'Hermione', 'middle': 'Jean', 'last': 'Granger', 'birth': 1979}
{'first': 'Neville', 'middle': None, 'last': 'Longbottom', 'birth': 1980}
{'first': 'Parvati', 'middle': None, 'last': 'Patil', 'birth': 1979}
{'first': 'Harry', 'middle': 'James', 'last': 'Potter', 'birth': 1980}
{'first': 'Dean', 'middle': None, 'last': 'Thomas', 'birth': 1980}
{'first': 'Romilda', 'middle': None, 'last': 'Vane', 'birth': 1981}
{'first': 'Ginevra', 'middle': 'Molly', 'last': 'Weasley', 'birth': 1981}
{'first': 'Ronald', 'middle': 'Bilius', 'last': 'Weasley', 'birth': 1980}

Given that I appear to be getting the right outputs in my terminal, I'm kind of at my wit's end. If anyone has any suggestions, they would be much appreciated. Also, here is my import.py code, in case that is the problem:

code removed in keeping with course's policy on academic honesty 

Many thanks for your wisdom and generosity.

0

It's not the output that's a problem, it's the input. Program takes the name of the data file as a command line argument, but ignores that here with open("characters.csv", "r") as characters:.

3
  • Ah, I absentmindedly hardcoded it, thereby making it work in the IDE but fail if check50 tried another CSV file. Well that was dumb. Thank you very much for your help
    – cmk273
    Jan 25 '20 at 19:57
  • @DinoCoderSaurus it seems i am having the same problem as @cmk273, however i have not hardcoded the name of the file i want to open --> with open(sys.argv[1], "r") as names:python what am i doing wrong ?
    – rassenguy
    Jan 29 '20 at 21:06
  • This should be posted as a new question, since your code does not (seem to) have the same problem as the original question. Jan 29 '20 at 21:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .