0

Assume that a file containing a series of names ( as strings ) is named names.dat and exists on the computers disk. Design a program that displays the numbers of names that are stored in the file. ( Hint: Open the file and read every string stored on it. Each time you read a string, increment a counter variable. When you've read all the strings from the file, the counter variable will contain the number of names stored in the file.)

2
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by sepp2k
0

Hint: Open the file and read every string stored on it. Each time you read a string, increment a counter variable. When you've read all the strings from the file, the counter variable will contain the number of names stored in the file.

That sounds about right. So why don't you go ahead and do that then?

0

hahha, thanks alot! No that's an excercise I'm doing, but I need to know where to start... before you start sending me python links, I haven;t found those to be helpful... I'm more of a visual learner, if you can show me an example of doing this ( not solving this exact problem) but where to start that would help. Or a site that shows python examples like that. I'm teaching myself python so it's been a rough road so far...

0

figured it out.. thought can't test it right? cause the names.dat doesnt exist....

0

thought can't test it right? cause the names.dat doesnt exist....

You can just create one. Open your favorite text editor, enter a bunch of names, save as names.dat in the directory where you run your python script from.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.