Here is my assignment with the directions. ###Programmer Brian Austin
###FOP
###3/30/09
###Assignment 8
###Using a loop, allow the user to input as many student names as they like and store the names in a list. in title format
#then write the list of names to a file named NAMES.
#Read your file back into a list and sort the list.
#Write the sorted list to a different file named SORTEDNAMES.
#Read in and print (on the screen) all the names of the SORTEDNAMES file.
#Add logic to handle file I/O error exceptions. You should include ALL I/O operations inside exception handling (open, read, write and close)
import cPickle
any_listnames=open("NAMES.TXT","w")
NAMES_list=["John", "Mary","Scott","Curly","Moe","Jon Doe"]
NAMES_file.close()
NAMES_list=cPickle.load(NAMES.file)
anylistnames=(raw_input("Enter as many student names as you have"))
print ("\nReading the entire file into a list.")
for line in anylistnames:
print line
try:
name= int(raw_input("Enter a name"))
except:
def _init_(names):
any_listnames=(NAMES.readlines.sort())
any_listnames.writelines(NAMES.title())
NAMESfile=open("NAMES.txt","r")
all_the_data=NAMES.read()
NAMES.close()
textfile = open("NAMES.txt", "r")
all_the_data=anyNAMES.read()
NAMES.close()
lines = NAMES.readlines()
print lines
print len(lines)
for line in lines:
print line
NAMES.close()
print "Opening and closing the file."
anylistnames= open("names.txt", "r")
namesfile.close()
print "\nReading the entire file at once."
anylistnames_file = open("names.txt", "r")
whole_thing = names_file.read()
print whole_thing
namesfile.close()
for line in any_files:
print line
anylistnames.writelines(NAMES_file.title())
anyNAMESfile=open("names.txt","r")
all_the_data=any_namesfile.read()
anyNAMESfile.close()
try:
name= int(raw_input("Enter a name"))
exce[t(ValueError),e:
print "Data entered was not a name", e
else:
print "The value of name is", name
i think it is because i don't have () in some areas.. can you fix it?