I am coding a quiz and I am trying to read line 2 from this file, reading the first line works but the second one gives me an error "IndexError: list index out of range" Here is the part of the code that gives me errors:
def business():
difficulty = input("Easy, Medium or Hard? ")
if difficulty == "easy":
score = 0
questions = open("buseasyquestions.txt","r")
answers = open("buseasyanswers.txt","r")
question1 = questions.readlines(0)[0].split("1")[0]
answer1 = answers.readlines()[0]
print(answer1 + "2) revenue + costs")
gues1 = int(input(question1 + " "))
if gues1 != 1:
print("Wrong, next question...")
if gues1 == 1:
score += 1
print("Correct! Next question...")
question2 = questions.readlines(1)[1].split("2")[0]
Oh and this is what the txt file says:
What is the formula for PROFIT?1 test2