<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_last_nonce(app, key, nonce):
 """ This method is only an example! Replace it with a real nonce database. :param str key: the public key the nonce belongs to :param int nonce: the latest nonce """

    if not hasattr(app, 'example_nonce_db'):
        # store nonces as a pair {key: lastnonce}
        app.example_nonce_db = {}
    if not key in app.example_nonce_db:
        app.example_nonce_db[key] = nonce
        return 0
    else:
        oldnonce = copy.copy(app.example_nonce_db[key])
        app.example_nonce_db[key] = nonce
        return oldnonce