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? :
If that doesn't work then you'll just need to do it in command line.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()
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.
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: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.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>")
\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.
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:
(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)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
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks