access next index in loop
I've got a text file containing the following lines:
what's you'r name?
my name is Micheal
how old are you?
I'm 33 year's old
filename= input("file name?\n")
try:
txt = open(filename+'.txt', 'r', encoding='utf-8').readlines()
print('could not find file name')
except FileNotFoundError:
print('could not fine file')
for count, line in enumerate(txt):
pass
for i in range(count+1):
print('Q',txt[i])
print('A',txt[i+1])
Text file contain question and answer, i try to make the output like:
question
answer
question
answer
like as it is in text file.