[Tutor] Tutor Digest, Vol 54, Issue 72
Lie Ryan
lie.1296 at gmail.com
Thu Aug 21 19:43:53 CEST 2008
On Wed, 2008-08-20 at 23:06 +0200, tutor-request at python.org wrote:
>
> Message: 6
> Date: Wed, 20 Aug 2008 23:50:55 +0300
> From: "Dotan Cohen" <dotancohen at gmail.com>
> Subject: Re: [Tutor] Reformatting phone number
> To: python-tutor. <tutor at python.org>
> Message-ID:
> <880dece00808201350m2410bfaar36167195408b8142 at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> I have gotten a bit farther, but I cannot get this to work as
> described in the previous mail:
>
> #!/usr/bin/env python
> import sys
> preNumber = sys.argv[1]
> if preNumber[0] == 0:
Python is strictly typed (unlike some languages like Javascript), you
cannot compare a string with a number although the string only contains
numbers. sys.argv[...] is a list of strings so preNumber[0] is a string,
while 0 is an integer.
> number = '+972' + preNumber[1:]
> else:
> number = '+' + preNumber
>
> Where is my flaw?
More information about the Tutor
mailing list