Skip to content
Advertisement

Creating sets of specific extracted values from a .txt file (Python)

I have a .txt file that says “NAMES,” “POINTS” and “SUMMARY” in capital letters, each followed by lines containing data. Each of these three groups is separated by an empty line:

JavaScript

My goal is to create three separate sets of names, points and summary.

I already created a set of names using the following code (which outputs a set of all names as intended):

JavaScript

However, I am unsure on how to create a set of points and a set of summary given they’re after an empty line and not at the start of the code unlike names. Any help would be greatly appreciated!! Thank you in advance <3

Advertisement

Answer

here is my solution:

JavaScript

It simple and could be done better but this will work for you I guess.

EDIT: more “pretty” vesrion:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement