fh1
Active Coder
hello i haven’t used this website in a while, but i wanted to show one of my scripts and ask for some feedback to make it a bit better 🙂
wow this website changed a lot. If you experience errors please tell me.
Python:
import os
createdNotes = []
createdFolders = []
print("Welcome to the note app!")
while True:
createnote = input("Type create to create a note (or folder), press R to read one, press V to view all notes and folders you made, press D to delete a note or a folder or press E to exit.\n ")
createnote = createnote.lower()
if createnote == "d":
removeNote = input(f"Which note or folder would you like to delete? (type in the note or folder) notes: {createdNotes}. folders: {createdFolders} ")
try:
os.remove(removeNote)
print("Deleted!")
continue
except:
print("An error occured, file doesn't exist.")
try:
os.rmdir(removeNote)
print("Deleted!")
continue
except:
print("An error occured, folder doesn't exist.")
elif createnote == "v":
print(f"Your notes: {createdNotes}. Your folders: {createdFolders}")
elif createnote == "r":
readnote = input("What note would you like to read? ")
try:
read = open(readnote, "r")
print(read.read())
read.close()
continue
except:
print("An error has occured.")
continue
elif createnote == "e":
print("goodbye")
break
elif createnote == "create":
createnote2 = input("Type write to write on a existing note, type folder to create a folder, or type create to make a new note.")
createnote2 = createnote2.lower()
if createnote2 == "folder":
nameFolder = input("What would you like to name your folder? ")
try:
os.mkdir(nameFolder)
print("Folder made!")
createdFolders.append(nameFolder)
continue
except:
print("An error has occured")
elif createnote2 == "write":
whichnote = input("What note would you like to write on?")
try:
note = open(whichnote, "a")
whatToWrite = input("What would you like to note? ")
append = open(whichnote, "a")
append.write(whatToWrite)
print("noted!")
append.close()
continue
except:
print("an error occured.")
continue
elif createnote2 == "create":
namenote = input("What would you like to name your note? ")
try:
note = open(namenote, "x")
createdNotes.append(namenote)
whatToWrite = input("What would you like to note? ")
append = open(namenote, "a")
append.write(whatToWrite)
print("noted!")
append.close()
continue
except:
print("an error occured")
continue
wow this website changed a lot. If you experience errors please tell me.