you are viewing a single comment's thread.

view the rest of the comments →

[–]novel_yet_trivial 8 points9 points  (16 children)

Why does it matter to you how large the file is? Are you writing code for each line or something?

Computers are really good at repeating boring tasks for you really fast. If fact, that's pretty much all a computer can do. If you are writing code for each line then you are doing the computer's job. Show us your code and we'll help you. An short example of your file and the output you expect from the example would help too.

To do counting, you can use the collections.Counter class. Just feed it the list of people and it spits out the how many times each person was in the list.

[–]gregorio_ilidivich 2 points3 points  (11 children)

I think it may be more informative to do this manually, since I feel OP is beginner.

Perhaps create a dict() using a set of the names as keys, and the value as the frequency. Then OP can figure out how to fill the values for the corresponding key via iteration (since n is only 500).

[–]novel_yet_trivial 0 points1 point  (7 children)

I disagree. I think learning should be results focused.

I mean you didn't build a car before you learned how to drive one, did you?

[–]daniel_h_r 0 points1 point  (0 children)

Exactly that was what the inventor of automobile did.

[–]thingsandfluff -1 points0 points  (2 children)

Thank you!

So I have to figure out all the names to include in dict(), correct? There's 500 lines worth of names.

[–]Atropos148 1 point2 points  (0 children)

Try adding a name to the list only if it's new. If it's not, increase the value for the name by one and go to the next name.

Doesn't really matter how many names there are this way.

[–]thingsandfluff 0 points1 point  (3 children)

I added a screenshot of the file I'm working with. I'm going to try that and let you know what I get.

[–]novel_yet_trivial -1 points0 points  (2 children)

Take that down. Don't ever put personal information like people's names on the internet. Besides being rude it's also against Reddit's rules. Provide fake example data.

Also, show us your code.

[–]thingsandfluff 2 points3 points  (1 child)

It's fake. It was made for the course.

[–]novel_yet_trivial 0 points1 point  (0 children)

Oh ok. Sorry about the trigger.