Ah, here it is. Minor surgery as they say ...
fileHandle = open ( 'stuff.txt', 'r' )
# read into a list of dataline strings
data = fileHandle.readlines()
fileHandle.close()
# slice off the trailing new line character of each line
data[0] = data[0][:-1]
data[1] = data[1][:-1]
data[2] = data[2][:-1]
data[3] = data[3][:-1]
# convert to sublists, split at the commas
Idnum = data[0].split(",")
Name = data[1].split(",")
Major = data[2].split(",")
GPA = data[3].split(",")
# test it ...
print Idnum
print Name
print Major
print GPA
# this may be a little too much text for the input prompt
#task = input("Press 1 to select a student. Press 2 to alter GPA. Press 3 to print Dean's List.")
task = 1 # testing
if task == 1 :
student = raw_input("Enter student id number: ")
count = 0
while (count < len(Idnum)) :
if student == Idnum[count] :
index = count
print Idnum[index]
print Name[index]
print Major[index]
print GPA[index]
count = count+1
... and here is the modified data file:
5555,2323,1001,9999,3428,5920,3012,8954,7834,3490
John Smith,Nancy Doe,Eric Adams,Homer Simpson,Marilyn Monroe,Rory Gilmore,Gavin Degraw,Ashley Simpson,Brad Paisley,Dr. Phil
Computer Science,Electrical Engineering,Biology,Physical Education,Communications,Pre-Law,Music,Chorus,History,Psychology
3.2,4.0,3.8,1.2,3.5,4.0,3.4,1.4,3.6,2.7
Actually you can use other delimiters, something that doesn't interfere with your data content.