I have a program due and I cannot figure it out! I have read about 30 tutorials to no avail! I need to have data read into python from an input file. The data is suppossed to be info from a pretend university that only has 10 students. Once I figure out how to input the data I should be able to do the rest but right now I am stumped!
mneaker
0
Newbie Poster
Recommended Answers
Jump to PostYou need to let us know what kind of a data file this is. If it is just a text file, you can read the whole thing into a string and go from there ...
# read the entire text from a file into a string fileHandle …
Jump to PostI assume from your limited info that each student's data is on a separate line. In this case you can read the file into a list of data lines ...
# read the data from a file into a list of data lines fileHandle = open ( …
Jump to PostThe numbers in your Idnum list are strings. Input() gives you an integer number. Now you are trying to compare a string with an integer, that will always be false! Use raw_input() to get a string ...
Idnum = ['5555', '2323', '1001', '9999', '3428', '5920', '3012', '8954', …
Jump to PostAgain, your GPA list consists of strings and you are comparing this with a floating point number. Convert the string to a float with float() and then compare ...
GPA = ['3.2', '4.0', '3.8', '1.2', '3.5', '4.0', '3.4', '1.4', '3.6', '2.7'] Name = ['John Smith', 'Nancy Doe', …
All 14 Replies
vegaseat
1,735
DaniWeb's Hypocrite
Team Colleague
mneaker
0
Newbie Poster
vegaseat
1,735
DaniWeb's Hypocrite
Team Colleague
mneaker
0
Newbie Poster
vegaseat
1,735
DaniWeb's Hypocrite
Team Colleague
mneaker
0
Newbie Poster
vegaseat
1,735
DaniWeb's Hypocrite
Team Colleague
kyle.tk
0
Newbie Poster
vegaseat
1,735
DaniWeb's Hypocrite
Team Colleague
mneaker
0
Newbie Poster
vegaseat
1,735
DaniWeb's Hypocrite
Team Colleague
mneaker
0
Newbie Poster
vegaseat
1,735
DaniWeb's Hypocrite
Team Colleague
mneaker
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.