Sorry if I did someting wrong, is my first post.
I want to know how can I put this program in a def function.
thanks in advance.
file = open("Moradores.txt", "a+")
file1 = open("Moradores.txt", "r", encoding="utf-8")
lerFile = file1.read()
mName = input("Nome: ")
if mName in lerFile:
while True:
print("O nome ja existe, tente outro")
mName = input("Nome: ")
if mName not in lerFile:
break
mEmail = input("Email: ")
mPass = input("Senha: ")
file.write(mName + "|")
file.write(mEmail + "|")
file.write(mPass + "|")
file.write("\n")
print("Continue registering?")
print("1 - YES || 2 - NO")
choice = input()
if choice == '2':
break
elif choice != '1':
print("Invalid option")
print("Continue registering?")
print("1 - YES || 2 - NO")
choice = input()
file.close()
def your_function():at the start?