I am a beginner with python and I am unsure what I should be searching for with regards to my assignment. I am trying to find a way to manipulate a text file to the output format required.
The question is as follows: "Write a program that reads the data from the text file called ‘DOB.txt’ and prints it out in two different sections."
DOB text file reads (Name, Surname and DOB per line):
Orville Wright 21 July 1988
Rogelio Holloway 13 September 1988
Marjorie Figueroa 9 October 1988
Debra Garner 7 February 1988
Tiffany Peters 25 July 1988
Hugh Foster 2 June 1988
Darren Christensen 21 January 1988
Shelia Harrison 28 July 1988
Ignacio James 12 September 1988
Jerry Keller 30 February 1988
Pseudo code as follows:
Read the file DOB.txt
create a loop that will go over the contents being read from the File
display every line being read ( this will have the name and the DOB of the
students)
Use string indexing to get the first name and the 2nd name
assign this to a variable and print the first name and surname
For example something like this first_name = name[0] + name[1]
Keep in mind the name is the iterator that will be looping over the file we
are reading too.
DO the same to the DOB ( use string indexing to get the DOB of the student )
Counter for numbering each name
counter for numbering each surname
open file for reading
store contents of file in the form of lines
loop through contents
split each line into words
access the word and charcaters using indexing
Expected results are as per below:
Name:
- Orville Wright
- Rogelio Holloway
- Marjorie Figueroa
- Debra Garner
- Tiffany Peters
Birth Date:
- 21 July 1988
- 13 September 1988
- 9 October 1988
- 7 February 1988
- 25 July 1988