Thread: print

  1. Only the strong survives!!.
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Feb 2003
    A World of wonders.
    Rep Power


    Can anyone tell me why this is printing a 0 at the begining?
    i tryed coding this like if i was coding in c hehe so anyhelp why?

    import time
    import os
    print "Getting readdy to blast off!"
    for i in range(1, 11):
        print os.system("cls")
        print i
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Hull, UK
    Rep Power
    Hey X, firstly, you don't have to print os.system() since results are sent directly to sys.stdout...

    theres what the docs say about os.system()

    system( command)

    Execute the command (a string) in a subshell. This is implemented by calling the Standard C function system(), and has the same limitations. Changes to posix.environ, sys.stdin, etc. are not reflected in the environment of the executed command.
    On Unix, the return value is the exit status of the process encoded in the format specified for wait(). Note that POSIX does not specify the meaning of the return value of the C system() function, so the return value of the Python function is system-dependent.

    On Windows, the return value is that returned by the system shell after running command, given by the Windows environment variable COMSPEC: on systems (Windows 95, 98 and ME) this is always 0; on cmd.exe systems (Windows NT, 2000 and XP) this is the exit status of the command run; on systems using a non-native shell, consult your shell documentation.

    Availability: Unix, Windows.
    Ok, so basically just don't print it and you'll be fine

    programming language development: Hula

IMN logo majestic logo threadwatch logo seochat tools logo