-
-
Save anonymous/fa367ff6955b10ae6e11 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class entry(object): | |
""" | |
This creates a new Type called an entry | |
""" | |
__slots__ = ('name', 'gender', 'rank') | |
def mkEntry(name, gender, rank): | |
""" | |
This makes the Entry and reads what is inside it, assigning it | |
to a variable | |
""" | |
ent= entry() | |
ent.name = name | |
ent.gender = gender | |
ent.rank = rank | |
return ent | |
def main(): | |
lst = [] | |
year = input('Enter Year: ') | |
inputFile= open('names/yob' + year + '.txt') | |
flst = [] | |
mlst = [] | |
for line in inputFile: | |
line = line.strip().split(',') | |
name = mkEntry(line[0], line[1], line[2]) | |
lst.append(name) | |
if name.gender == 'F': | |
flst +=[line] | |
else: | |
mlst +=[line] | |
while len(lst) > 20: | |
male = mLst.pop() | |
female = flst.pop() | |
if mlst.rank > flst.rank: | |
lst += [male] | |
""" | |
All this is doing is displaying the location of the file not the list | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment