[Tutor] Rounding to n significant digits? (original) (raw)

Gregor Lingl glingl at aon.at
Mon Jul 5 00:10:50 CEST 2004


Hello Dragonfirebane!

You have to start the code from the commandline:

Do you run windows?

then write something like:

C:\mycode> python contest.py 1526985643

and you will get the output. The integer 1526985643 (or any other one) is the input to the program and (automatically) stored in sys.argv[1]

(I think argv stands for argument-vector)

C:\mycode> c:\python23\python.exe contest.py 1526985643

If python isn't on your path you have to write something like:

Alternately you can use the Pythonwin IDE, where you can input arguments to a program in a special dialog when you run it.

If all this doesn't work for you, last resort is to replace sys.argv[1] directly by the input-string:

for c in "1526985643": ....

HTH, Gregor

Dragonfirebane at aol.com schrieb:

I tried out your code (for the contest) and it says that there is no sys.argv[1] (List index out of range). When i try it with sys.argv[0] it says "invalid literal for int(): C".

Email: dragonfirebane at aol.com AIM: singingxduck Programming Python for the fun of it.



More information about the Tutor mailing list