I have to read a text file (notepad txt) which is in the format of:
Why are manhole covers round in shape?
The cover cannot fall through if it is circular._Circular covers do not need to be precisely aligned._A round cover is easy to move and roll._Human beings have a roughly circular cross section._All of the above.
5
What is the result of dividing 3 by 4?
1.33333...._0.75._12._7._7._0.7777777777777
2
In the series 1,2,3,4,5,...100, how many of these numbers have the digit 7 in them?
9._10._19._20._11
3
The answers are separated by (._) and the answer is the number that follows the question as it coresponds to the answer choices.
I want to have each set of questions stored as a tuple in a list. And I want to display on screen in the format as shown below.
1.Question
1)First option
2)Second option
3)Third option
#etc as there are more answers for some of the questions
2. Question
1) First option
2) Second option
3) Third option
#etc as there are more answers for some of the questions
How do I write code to do so? Thanks for the help!
答案 0 :(得分:1)
To pull this off you will need to do a couple steps.
._
delimiter and store the resulting array in another temporary variable (https://docs.python.org/2/library/string.html#string.split)