Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Progrogramming
#1
I need to rite a function in this file called nine_lines that uses a function called three_lines to print nine blank lines. I then want to add a function named clear_screen that prints out twenty-five blank lines. The last line of your program should call the function to clear_screen. Please help me, my scripts give me invalid syntax when I run it.

Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> def new_line():
print()
def three_lines():
new_line()
new_line()
new_line()
def nine_lines():
print("Now Calling three_lines function...")
print three_lines()

def three_lines():
print("printing line one")
print("printing line two")
print("printing line three")
print("printing line four")
print("printing line five")
print("printing line six")
print("printing line seven")
print("printing line eight")
print("printing line nine")

print three_lines()
def clear_screen():
print("Now Clearing screen...from screen_line function")
print("printing line one from clear screen")
print("printing line two from clear screen")
print("printing line three from clear screen")
print("printing line four from clear screen")
print("printing line five from clear screen")
print("printing line six from clear screen")
print("printing line seven from clear screen")
print("printing line eight from clear screen")
print("printing line nine from clear screen")
print("printing line ten from clear screen")
print("printing line eleven from clear screen")
print("printing line twelve from clear screen")
print("printing line thirteen from clear screen")
print("printing line fourteen from clear screen")
print("printing line fifteen from clear screen")
print("printing line sixteen from clear screen")
print("printing line seventeen from clear screen")
print("printing line eighteen from clear screen")
print("printing line nineteen from clear screen")
print("printing line twenty from clear screen")
print("printing line twenty one from clear screen")
print("printing line twenty two from clear screen")
print("printing line twenty three from clear screen")
print("printing line twenty four from clear screen")
print("printing line twenty five from clear screen")
print clear_screen()
Reply
#2
Please put your code in Python code tags and errors in error tags. You can find help on that here.
Reply
#3
When you want to call a function, you don't need to put print before it:

three_lines()

or

print(three_lines())

rather than

print three_lines()

Note. print(three_lines()) will print None as that is what is returned from your functions by default in the absence of a return statement. That will be in addition to any output the function produces.
I am trying to help you, really, even if it doesn't always seem that way
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020