[Tutor] referencing a dictionary

Daniel Yoo dyoo@hkn.EECS.Berkeley.EDU
Tue, 18 Jul 2000 10:03:09 -0700 (PDT)


On Tue, 18 Jul 2000, brian callahan wrote:

> thankyou for the advice, my input would look like
> 
> afhalkjdsahlahf
> 
> and then the dictionary looks like {a : 123} etc.
> 
> i think i need to go somthing like 'sum = sum + dict [char]'


That sounds like a good way to do it.

Strings, too, are a sequence type, so you can iterate through each letter
of a string using a for loop:

for acid in "afhalkjdsahlahf":
  ...


Good luck!