I'm trying to display a bunch of lines from a text file as a table. The text file looks something like this:
capital|What is the capital of Egypt?|Cairo|3
pi|What is pi to two digits?|3.14|3
dozen|How many eggs in a dozen?|12|1
president|Who was the first president?|Washington|1
I'd like to have my code spit out a formatted output that would look something like this:
capital What is the capital of Egypt? Cairo 3
pi What is pi to two digits? 3.14 3
dozen How many eggs in a dozen? 12 1
president Who was the first president? Washington 1
Here's the code I've come up with, but the output is nowhere near looking like the way I want it to.
f = open('quest_load.txt', 'r')
contents = f.read()
contents1 = contents.replace('|',' ')
print(contents1)
f.close()