> ###
> >>> d = {}
> >>> def addTally(name):
> ... d.setdefault(name[0], []).append(name)
> ...
> >>> addTally('john')
> >>> addTally('brian')
> >>> addTally('jane')
> >>> addTally('alice')
> >>> addTally('bob')
> >>> d
> {'a': ['alice'], 'j': ['john', 'jane'], 'b': ['brian', 'bob']}
> ###
>
>
On Tue, 1 Mar 2005, James O. Sweeney wrote:
> I have an assignment that entails entering cash transactions as records.
Hi James,
Just to make it clear: we are prohibited from doing homework questions.
Since it's an assignment, we'll try to stay clear of direct solutions.
> My question is ab
While we generally don't get too specific with assignments and/or homework -
For a traditional database, you'd have to go the mySQL route. A
dictionary is good, but for only one discreet key. That said, you
could do it with objects like this -
dictOfTransactionObjects = {}
class CashTransaction
Hello,
I have an assignment that entails entering cash transactions
as records. The significant record fields are a date/time stamp, the amount,
and whether the transaction is a deposit or withdrawal. My question is about setting
up the database file. In Python there is a dictionary functi