Write a function named inputRoster that prompts a user for the name of a class r
ID: 3566781 • Letter: W
Question
Write a function named inputRoster that prompts a user for the name of a class roster. The function has no parameters. This roster has names in the format lastName,firstName (no spaces). Your function should read this file, and create a new roster file with the format firstName lastName (one space between names, no comma). Your program MUST be written to prompt the user for the name of the roster file to be read. The new roster that your program creates MUST be output to a file named rosterFirstLast.txt (Note: there are no blanks in this file name).Explanation / Answer
def InputRoster():
print 'Enter The roster Filename to be read'
f1 = raw_input()
ofile = open(f1,'r')
wfile = open("rosterFirstLast.txt",'w')
for lines in ofile:
s = lines.split(',')
wfile.write(s[0]+' '+s[1]);
wfile.close()
InputRoster()
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.