Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Using Databases in Python Our Diary App Switching It Up

Ashley Keeling
Ashley Keeling
11,476 Points

the quit part of the function isn't working

i am not sure if it is supposed to but in the video it worked for him, everything else is working

!/usr/bin/env python3

from collections import OrderedDict import datetime

from peewee import *

db = SqliteDatabase('diary.db')

class Entry(Model): content = TextField() # content timestamp = DateTimeField(default=datetime.datetime.now) # timestamp

class Meta:
    database = db

def initialize(): """create the database and the table if they font exist""" db.connect() db.create_tables([Entry], safe=True)

def menu_loop(): """SHOW THE MENU""" choice = None

while None != 'q':
    print("enter 'q' to quit")
    for key, value in menu.items():
        print("{}) {}".format(key, value.__doc__))
    choice = input('Action: ').lower().strip()

    if choice in menu:
        menu[choice]()

def add_entry(): """add an entry"""

def view_entries(): """view previous enteries"""

def delete_entry(entry): """delete an entry"""

menu = OrderedDict([ ('a', add_entry), ('v', view_entries), ])

if name=='main': initialize() menu_loop()

1 Answer

while None != 'q':

did you meant choice != 'q'