Midterm2 - if position in Dict print"These players...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
inputFile=open("baseball.csv","r") Dict={} for line in inputFile: line=line.strip() linelist=line.split(",") if linelist == "Name": continue position= linelist[1] name=linelist[0] if position in Dict: Dict[position]=Dict[position]+[name] else: Dict[position]=[name] inputFile.close() while True: position=raw_input("Enter a position (P, 1B, 2B, 3B, C, SS, OF) or return")
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: if position in Dict: print "These players play", position+":" for person in Dict[position]: print person elif position == "": print "Exiting" break else: print "There is no position", position+"."...
View Full Document

Ask a homework question - tutors are online