0
print("      This is the test for floyds formation     ")

def flyod(n):
    a=1
    for i in range(1,n+1):
        for j in range(i):
            print(a,end=" ")
            a+=1
        print()   
    print()
n=input("Enter the number of rows baby : ")
flyod(n)

Getting syntax error on end=" " receiving "There is an error in your program: invalid syntax"

TerryA
  • 58,805
  • 11
  • 114
  • 143
satishKR
  • 1
  • 1
  • 1
    Python 2, perhaps? –  Apr 03 '18 at 11:48
  • 1
    Possible duplicate of [What does "SyntaxError: Missing parentheses in call to 'print'" mean in Python?](https://stackoverflow.com/questions/25445439/what-does-syntaxerror-missing-parentheses-in-call-to-print-mean-in-python) – Chris_Rands Apr 03 '18 at 11:54

1 Answers1

2

You're probably running your code with Python 2 as opposed to Python 3, where print is a function and not a statement.

Try running your code as such on your terminal:

$ python3 file.py

Where file.py is obviously replaced as the name of your file.

You might need to install Python 3.


If Python 3 is not an option for whatever reason, you can use print as a function by importing it:

>>> from __future__ import print_function
>>> print("Hello!", end=" ")
Hello! >>> 

Note that this will need to be done (the import statement) immediately at the top of your file.

TerryA
  • 58,805
  • 11
  • 114
  • 143