Question: This lab is for file processing. (see textbook P153-157). Or read Week 10 Weekly module. 1. You prepare a .txt file with about 5-10 student
This lab is for file processing. (see textbook P153-157). Or read Week 10 Weekly module.
1. You prepare a .txt file with about 5-10 student names. One name per line, e.g.: John Doe. Save it as you like, on a location you preferred (very important to know the location of this file.)
2. You prepare an EMPTY .txt file. Save it as you like, on a location, you preferred (very important to know the location of this file.)
3. Revise the userfile.py (Page 157) to to generate some kind of student email address within Western Online internal email system, let's see it should be: j-doe@westernonline.wiu.edu, by using first letter of first name and last name (no more than 7 letters long). So this userfile_v2_YourLastName.py you created can do the batch user email address process.
4. What to submit? a .txt file with about 5-10 student names; a .txt file with about 5-10 student Western Online internal email address; a revised userfile_v2_YourLastName.py copy/pasted on .txt file. (so you will have 3 .txt file attached separately. Don't zip them.)
I am having problems with the (3.) part of the question. I'm trying to figure out how to create an internal email address.
Coding so far:
def main(): print("This program creates a file of usernames from a") print ("file of names.")
#file locator infileName=input("What file are the names in? ") outfileName=input("What file should the usernames go in? ")
#Import file names infile = open(infileName,"r") outfile = open(outfileName,"w")
#Process input file lines for line in infile: #get first and last name from line first, last,= line.split() #Username created uname = (first[0]+last[:7]).lower() #Written to Output file print(uname, file=outfile)
#close files infile.close() outfile.close()
print("Usernames have been written to", outfileName)
main()
I think I may need to add a to the first and last name but I'm unsure of how to do this?
**Edit: I figured out what I was doing wrong!
Coding for the Email address add is **uname = (first[0]+"-"+last[:7]+"@westernonline.wiu.edu").lower()**
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
