I'm Sure There's A Better Way
phawkins at spamnotconnact.com
phawkins at spamnotconnact.com
Mon Jul 9 13:37:38 EDT 2001
>>>>> "AM" == Aahz Maruch <aahz at panix.com> writes:
AM> In article <3b4676ad$0$324$8eec23a at newsreader.tycho.net>,
AM> Neil Macneale <mac4-devnull at theory.org> wrote:
>>
>> Note: this sollution requires 2 characters after the decimal point....
>>
>> def isDollarAmount(s):
>> try:
>> if s.count == 1 and s[-3] == '.':
>> dol, cen = s.split('.')
>> int(dol)
>> int(cen)
>> return 1
>> int(s)
>> return 1
>> except:
>> return None
AM> I would change "int(dol)" to "long(dol)".
And s.count to s.count('.')
Otherwise, cute.
--
Patricia J. Hawkins
Hawkins Internet Applications, LLC
More information about the Python-list
mailing list