def main():
print("this program creates a file of usernames from a ")
print("files of names ")
# get the file names
infilename = input("what files are the name in")
outfilename = input("what file should the usernames go in")
# open the files
infile = open(infilename,'r')
outfile = open(outfilename,'w')
# process each line of the input file
for line in infile.readlines():
# get the first and last names from line
first, last = line.split()
# create the username
uname = line.lower(first[0]+last[:7])
# write it to the output file
outfile.write(uname+'\n')
# close both files
infile.close()
outfile.close()
print("usernames have been written to : ", outfilename)
main()
I am trying to write a program that takes a bunch of first names and last names from a file and then print a usernames from that which is combination of the first letter from the first name and rest from the last name. Example: alex
doug
will be adoug
.
The python interpreter show an error on uname = line.lower(first[0]+last[:7])
.
TypeError lower() takes no arguments (1 given)
Is there any way around this error or is there any other way to do it?