I am very new to programming. I want to be able to run this program for both entries in my list but do not understand programming enough to get it right. Members of this site have helped me get this far, and the program works great for one set of tags. I want it to run so I can search multiple authors in one pass. The output is that it only gathers all the information for "Shakes." and then stops. I just do not know how to format the loops to make it right.
Here is the code I am working with:
authorList = ['Shakes.','Scott']
with open('/Users/Adam/Desktop/Poetrylist.txt','w') as output_file:
with open('/Users/Adam/Desktop/2e.txt','r') as open_file:
the_whole_file = open_file.read()
start_position = 0
for x in authorList:
while True:
start_position = the_whole_file.find('<A>'+x+'</A>', start_position)
if start_position < 0:
break
end_position = the_whole_file.find('</W>', start_position)
output_file.write(the_whole_file[start_position:end_position+4])
output_file.write("\n")
start_position = end_position + 4
I am sure this is a very simple problem, but I am trying to teach myself python and it is going quite slowly.