πŸ“– Beginning Python Programming /
Module: List & Collection

Code Example: Random Quote

πŸ“– Beginning Python Programming / List & Collection / Code Example: Random Quote

Quote Example v5

from random import choice
from collections import namedtuple

Quote = namedtuple("Quote", "quote, source")

quotes = (
    Quote(quote="I want to put a ding in the universe.", source="Steve Jobs"),
    Quote(quote="Life is 10% what happens to you and 90% how you react to it.", source="Charles R. Swindoll"),
    Quote(quote="Family is not an important thing. It's everything.", source="Michael J. Fox"),
    Quote(quote="Nothing is impossible, the word itself says 'I'm possible'!", source="Audrey Hepburn"),
    Quote(quote="There are two ways of spreading light: to be the candle or the mirror that reflects it.", source="Edith Wharton"),
    Quote(quote="Try to be a rainbow in someone's cloud.", source="Maya Angelou"),
    Quote(quote="Be brave enough to live life creatively. The creative place where no one else has ever been.", source="Alan Alda"),
    Quote(quote="The secret of getting ahead is getting started.", source="Mark Twain"),
)

quote = choice(quotes)
print(f'β€œ{quote.quote}” β€” {quote.source}')