Closed Thread
Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: what's the problem

  1. #11
    Join Date
    Jun 2010
    Location
    Vancouver, Eh.
    Posts
    4,020
    Blog Entries
    7
    Rep Power
    39

    Re: what's the problem

    Quote Originally Posted by manux View Post
    If you want to run a test script from the Python shell[..]
    That wasn't his problem, in his interactive shell newlines do not appear for whatever reason, we were helping him to access the script directly from the command prompt to show it works (as it's a school project).

    EDIT: jivkoss, try running the same script but with explicitly setting newlines? :
    Code:
    #tryme3.py
    
    def three_lines():
        print "\n"
        print "\n"
        print "\n"
    
    def nine_lines():
        three_lines()
        three_lines()
        three_lines()
    
    print ("First line")
    nine_lines()
    print ("Nineth line")
    
    def clear_screen():
        nine_lines()
        nine_lines()
        three_lines()
        three_lines()
    
    print ("twenty-five blank lines")
    clear_screen()
    If that doesn't work then you'll just need to do it in command line.
    Be sure to read the updated FAQ || Health is achieved through 10,000 different steps.
    A textual description can be only part of your question, be sure to provide sample results, errors and your platform in the appropriate forums while asking.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #12
    jivkoss is offline Newbie
    Join Date
    Jun 2010
    Location
    Kazanlak/Bulgaria/Europe/Earth/Solar System/ Milky Way Galaxy/Somewhere in the Universe
    Posts
    28
    Rep Power
    0

    Re: what's the problem

    Thanks for the idea of printing "/n" for an empty line instead of just using print. It gave me syntax error at 1st because "/n" should be in brackets. This code works just fine:
    Code:
    #tryme3.py
    
    def three_lines():
        print ("\n")
        print ("\n")
        print ("\n")
    
    def nine_lines():
        three_lines()
        three_lines()
        three_lines()
    
    print ("First line")
    nine_lines()
    print ("Nineth line")
    
    def clear_screen():
        nine_lines()
        nine_lines()
        three_lines()
        three_lines()
    
    print ("twenty-five blank lines")
    clear_screen()
    
    input("Press<enter>")
    I also added the last line in order to execute the program in the command prompt so it doesn't close instantly after the program executes.

  4. #13
    Join Date
    Jun 2010
    Location
    Vancouver, Eh.
    Posts
    4,020
    Blog Entries
    7
    Rep Power
    39

    Re: what's the problem

    \n is a newline, so it's best you trust the output of a newline with that. I just wonder why your interactive shell didn't print new lines in the first place, it might be an older version?

    Glad we got it to work!
    Be sure to read the updated FAQ || Health is achieved through 10,000 different steps.
    A textual description can be only part of your question, be sure to provide sample results, errors and your platform in the appropriate forums while asking.

  5. #14
    manux's Avatar
    manux is offline Programming Professional
    Join Date
    Oct 2008
    Posts
    234
    Blog Entries
    1
    Rep Power
    14

    Re: what's the problem

    Well, if he's running Python 3.x, of course just writing print won't do anything , it's a function in Python 3 (vs a keyword in Python 2.x).
    It's like if you declared a function foo and just did:
    Code:
    def foo():
       print(123)
    foo() # calls foo, will print 123
    foo # just "foo" alone is a valid statement(no errors),
    # but it doesn't do anything, it doesnt call foo
    (I am guessing he is because he's using print as a function in the code he just posted, and he says there's an error if he doesn't use brackets)

Closed Thread
Page 2 of 2 FirstFirst 12

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. If problem or cout problem?
    By chaoticape in forum C and C++
    Replies: 4
    Last Post: 06-10-2011, 10:29 AM
  2. C: Problem with solving problem
    By rakche in forum C and C++
    Replies: 15
    Last Post: 03-28-2010, 01:24 PM
  3. Replies: 0
    Last Post: 04-26-2007, 05:33 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts