How can I resolve NameError?

Hello everyone~
Acctually I don’t know how to make the code of program.
But I’m intersted in Phython and I’m wathching Youtube and following the instruction.
And I encountered some unexpected problem.

This is no problem

import openpyxl

class Conversation:

def __init__(self, contentName, constentType, question, answer):
    self.contentName = contentName
    self.constentType = constentType
    self.question = question
    self.answer = answer
    
def __str__(self):
    return "Question : " + self.question + "\Answer : " + self.answer + "\n"

wb = openpyxl.load_workbook(“Terms.xlsx”)
ws = wb.active

conversations =

for r in ws.rows:
c = Conversation(r[0].value, r[1].value, r[2].value, r[3].value)
conversations.append©

wb.close()

for c in conversations:
print(str©)


But blow code have some problem

Exception has occurred: NameError name ‘conversations’ is not defined
File “C:\Users\listo\Downloads\Phython\output.py”, line 6, in prev = str(conversations[0].contentName) + str(conversations[0].contentType)

-- coding: utf-8 --

i = 1

prev = str(conversations[0].contentName) + str(conversations[0].contentType)
f = open(prev + ‘.json’, ‘w’, encoding=‘UTF-8’)
f.write(’{ “id”: “10d3155d-4468-4118-8f5d-15009af446d0”, “name”: “’ + prev + '”, “auto”: true, “contexts”: , “responses”: [ { “resetContexts”: false, “affectedContexts”: , “parameters”: , “messages”: [ { “type”: 0, “lang”: “ko”, “speech”: “’ + conversations[0].answer + '” } ], “defaultResponsePlatforms”: {}, “speech”: } ], “priority”: 500000, “webhookUsed”: false, “webhookForSlotFilling”: false, “fallbackIntent”: false, “events”: }’)
f.close()
f = open(prev + ‘_usersays_ko.json’, ‘w’, encoding=‘UTF-8’)
f.write("[")
f.write(’{ “id”: “3330d5a3-f38e-48fd-a3e6-000000000001”, “data”: [ { “text”: “’ + conversations[0].question + '”, “userDefined”: false } ], “isTemplate”: false, “count”: 0 },’)

while True:
if i >= len(conversations):
f.write("]")
f.close()
break;
c = conversations[i]
if prev == str(c.contentName) + str(c.contentType):
f.write(’{ “id”: “3330d5a3-f38e-48fd-a3e6-000000000001”, “data”: [ { “text”: “’ + c.question + '”, “userDefined”: false } ], “isTemplate”: false, “count”: 0 },’)
else:
f.write("]")
f.close()
prev = str(c.contentName) + str(c.contentType)
f = open(prev + ‘.json’, ‘w’, encoding=‘UTF-8’)
f.write(’{ “id”: “10d3155d-4468-4118-8f5d-15009af446d0”, “name”: “’ + prev + '”, “auto”: true, “contexts”: , “responses”: [ { “resetContexts”: false, “affectedContexts”: , “parameters”: , “messages”: [ { “type”: 0, “lang”: “ko”, “speech”: “’ + c.answer + '” } ], defaultResponsePlatforms": {}, “speech”: } ], “priority”: 500000, “webhookUsed”: false, “webhookForSlotFilling”: false, “fallbackIntent”: false, “events”: }’)
f.close()
f = open(prev + ‘_usersays_ko.json’, ‘w’, encoding=‘UTF-8’)
f.write("[")
f.write(’{ “id”: “3330d5a3-f38e-48fd-a3e6-000000000001”, “data”: [ { “text”: “’ + c.question + '”, “userDefined”: false } ], “isTemplate”: false, “count”: 0 },’)
i = i + 1


How can I resolve this problem?
Please, help me~

This means that you are using conversations without having defined it. Your formatting is very broken, but as far as I can tell this is a new Python script, entirely separate from the script you showed that works. In that case Python is quite right; conversations doesn’t exist there. You need to import it from your previous script, or copy and paste it into the start of your new script.