[Tutor] Individual Character Count

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Sat, 7 Sep 2002 16:24:58 -0700 (PDT)


> Your approach seems reasonable.  Once you've split the 'body' up, you
> already have enough information to count how many of that 'character' is
> in there: the number of 'character's should just be the number of
> in-betweens we have in our split-up body:
>
>    ['',       '',        '',           'bb',        'bb',        '']
>
> That is, if we have a list of six elements, the number of "in-between"
> places is just the number of commas we see in our list: 5.
>
> join ==>
>
>    '' + 'a' + '' + 'a' + '' + a + '' + 'bb' + 'a' + 'bb' + 'a' + ''


Hi Kyle,

Doh.  I messed up here in the diagram.  Forget those pictures above.  I
meant to write:


    l = ['',        '',        '',        'bb',        'bb',        '']

    'a'.join(l) ==>

         '' + 'a' + '' + 'a' + '' + 'a' + 'bb' + 'a' + 'bb' + 'a' + ''


instead, which tries to show better the relationship that join() has with
split().  My apologies for being sloppy about this.