Tiger12506 wrote:
>> Nope, if you read the code you'll see the only mapping done is up to 20
>> and then by tens up to 100, that's all.
>> The same code could be used with a list, you'd only have to change the
>> exception name.
>
> I see. There were "..." in between each of the tens entries which
> Nope, if you read the code you'll see the only mapping done is up to 20
> and then by tens up to 100, that's all.
> The same code could be used with a list, you'd only have to change the
> exception name.
I see. There were "..." in between each of the tens entries which I took to
mean that "big
Tiger12506 wrote:
>> Isn't dictionary access faster than list access? Why are three lists
>> 'much more efficient'?
>
> Oh no, no, no. Dictionaries are faster when you are *searching through* for
> a particular value. If you already know the index of the item in the list,
> lists are much faste
Danny Yoo wrote:
> [snip]
> First, it ignores zero, which is a cardinal sin.
Or is it an ordinal sin?
[snip]
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
On 24/01/2008, Ricardo Aráoz <[EMAIL PROTECTED]> wrote:
> Isn't dictionary access faster than list access? Why are three lists
> 'much more efficient'?
Well, not necessarily.
If you want a dictionary, you could use a list of tuples:
myDict = [('a', 'one'), ('b', 'two), ('c', 'three')]
Then you
> Isn't dictionary access faster than list access? Why are three lists
> 'much more efficient'?
Oh no, no, no. Dictionaries are faster when you are *searching through* for
a particular value. If you already know the index of the item in the list,
lists are much faster.
Dictionaries are hash ba
> This could be written much more efficiently. It can be done with only
> these
> lists~
> ones =
> ['zero','one','two','three','four','five','six','seven','eight','nine']
> teens =
> ['ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen']
What is it
Tiger12506 wrote:
>> up to a thousand (not tested)
>>
>> words = {0:'zero', 1:'one', 2:'two', 3:'three', ... , 10:'ten',
>> 11:'eleven', 12:'twelve', ..., 19:'nineteen',
>> 20:'twenty', , 90:'ninety', 100:'one hundred' }
>> def digitToString(n) :
>>try :
>>retStr = words[n]
> up to a thousand (not tested)
>
> words = {0:'zero', 1:'one', 2:'two', 3:'three', ... , 10:'ten',
> 11:'eleven', 12:'twelve', ..., 19:'nineteen',
> 20:'twenty', , 90:'ninety', 100:'one hundred' }
> def digitToString(n) :
>try :
>retStr = words[n]
>except KeyError :
>
Danny Yoo wrote:
> Hi Jason,
>
>
> Looking back at that Java code:
>
>
> static String convertDigitToEnglish(int d) {
> switch ( d )
> {
>case 1: return "one";
>case 2: return "two";
>case 3
Hi Jason,
Looking back at that Java code:
static String convertDigitToEnglish(int d) {
switch ( d )
{
case 1: return "one";
case 2: return "two";
case 3: return "three";
case 4: retu
11 matches
Mail list logo