Remove unwanted characters from column
Chris Angelico
rosuav at gmail.com
Mon Jan 27 10:19:59 EST 2014
On Tue, Jan 28, 2014 at 2:03 AM, <matt.s.marotta at gmail.com> wrote:
> On Monday, 27 January 2014 09:57:32 UTC-5, Chris Angelico wrote:
>> On Tue, Jan 28, 2014 at 1:23 AM, <matt.s.marotta at gmail.com> wrote:
>>
>> > If the farmID < 10:
>> > remove one character from the address column
>> > Elif farmID > 10:
>> > remove two characters from the address column
>>
>> What if farmID == 10?
>>
>> ChrisA
>
> Ok, sorry this is how it should be.
>
> If the FarmID < 10:
> remove one character from the address column
>
> If the FarmID > 9:
> remove two characters from the address column
>
> My issue is I can't figure out what statement to use to define FarmID.
More commonly, that would be written as
if farmID < 10:
# remove one character
else:
# remove two characters
Though this still suffers from the limitation of not handling 100 or
1000, so you might want to look at len(str(farmID)) instead.
ChrisA
More information about the Python-list
mailing list