Python “接收”;您的程序中有一个错误:“无效语法”;

Python “接收”;您的程序中有一个错误:“无效语法”;,python,Python,在end=”“receiving“您的程序中有一个错误:无效语法”您可能正在使用Python 2而不是Python 3运行代码,where和not是语句 尝试在终端上运行代码: 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="

在end=”“receiving“您的程序中有一个错误:无效语法”

您可能正在使用Python 2而不是Python 3运行代码,where和not是语句

尝试在终端上运行代码:

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)
其中,
file.py
显然被替换为文件名

您可能需要安装Python3


如果由于任何原因Python 3不是一个选项,您可以使用
print
作为函数:


请注意,这将需要在文件顶部立即执行(导入语句)。

您可能正在使用Python 2而不是Python 3运行代码,因为Python 3中没有语句

尝试在终端上运行代码:

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)
其中,
file.py
显然被替换为文件名

您可能需要安装Python3


如果由于任何原因Python 3不是一个选项,您可以使用
print
作为函数:


请注意,这需要立即在文件顶部执行(import语句)。

Python 2,也许?可能重复Python 2,也许?可能重复Python 2
>>> from __future__ import print_function
>>> print("Hello!", end=" ")
Hello! >>>