How do I extract information (percentage results) from 5 .txt files and
output it into a new txt file?
The problem that I am trying to solve is above.
The .txt files are shown below:
first .txt
Name: Hamish Everdeen
Age: 13
Subject 1: Maths 70%
Subject 2: Science 80%
Subject 3: English 60%
second .txt
Name: Jane Smith
Age: 13
Subject 1: Maths 70%
Subject 2: Science 80%
Subject 3: English 60%
third text
Name: John Smith
Age: 11
Subject 1: Maths 50%
Subject 2: Science 90%
Subject 3: English 2%
fourth text
Name: Mary Jane
Age: 15
Subject 1: Maths 34%
Subject 2: Science 67%
Subject 3: English 84%
fifth text
Name: Thomas Hammond
Age: 14
Subject 1: Maths 95%
Subject 2: Science 80%
Subject 3: English 92%
The output file should look like this:
Maths:
Hamish Everdeen got 70%.
Jane Smith got 70%.
John Smith got 50%.
Mary Jane got 34 %
Thomas Hammond got 95%.
Science:
Hamish Everdeen got 80%
Jane Smith got 80%
John Smith got 90%
Mary Jane got 67%
Thomas Hammond got 80%
English:
Hamish Everdeen got 60%
Jane Smith got 60%
John Smith got 2%
Mary Jane got 84%
Thomas Hammond got 92%
The only thing I know is that you can use the open() function and
dictionarys are involved. Thanks. Please answer quickly!
No comments:
Post a Comment