Day 61 - Help me understand

Question:
I don’t understand David’s solution because he’s using code that wasn’t covered in previous lessons (which he does way too often imo).

So how do I solve this using my code? I’m having an issue with the reverse.sort() function. I just can’t get this to work.

Or if my code is just bad, can someone help me understand what David is doing with [::-1] ?

Tutorial number: Day 61

Repl link: https://replit.com/@tyler58/day-61100days?v=1#main.py

from replit import db
import datetime
import os
import time

def addTweet():
  tweet = input("What do you want to tweet?\n")
  timestamp = datetime.datetime.now()
  key = f"mes{timestamp}"
  db[key] = tweet
  time.sleep(2)
  os.system("clear")

def viewTweet():
  keys = db.keys()
  tweetList = [(key, db[key]) for key in db.keys()]
  tweetList.sort(reverse=True)
  for key in keys[:10]:
    print(f"""{key}: {db[key]}""")

def twitter():
  while True:
    menu = input("Add or View tweets.\n").capitalize()
    if menu == "Add":
      addTweet()
      continue
    elif menu == "View":
      viewTweet()
      continue
    else:
      print("That's not an option. Try again.")
      continue
    time.sleep(2)
    os.system("clear")
  
twitter()

A post was merged into an existing topic: Day 061 - Project 61 : Twitter rip off