Hello. I am trying to append a sentence as the last line of the string story and I am getting this error. Massive thanks in advance!:
NameError Traceback (most recent call last)
Cell In[117], line 1
----> 1 sentences.append(plotsentenceconclusion())
NameError: name ‘sentences’ is not defined
def paragraphbuilder():
sentences = []
narrative = 0
if paracount > 1:
sentences.append(" ")
for _ in range(random.randint(1,50)):
y = random.randint(1,20)
if y in range(1, 4):
sentences.append(sentencetype1())
if y in range(5):
sentences.append(weathersentence1())
if y in range(6, 10):
sentences.append(subjectsentence1())
if y in range(11, 18):
sentences.append(settingsentence1())
if y in range(19, 20):
narrative = narrative + 1
if narrative == 1:
sentences.append(plotsentence1())
if narrative == 2:
sentences.append(plotsentence2())
sentences.append("\n")
return " ".join(sentences)
""" Generate story """
paracount = 1
while paracount < numberparas:
paragraphbuilder()
paragraph = paragraphbuilder()
print(paragraph)
story = story + paragraph
paracount += 1