我很沮丧我浏览了我的代码很多次,无法找出为什么我得到的这段代码的语法无效。任何帮助将不胜感激!谢谢。
def nameReverse():
name = str(input("Enter your full name: "))
testName = name.split()
if len(testName)>1:
firstName=testName[0]
lastName=testName[1]
print (lastName,firstName)
def main():
nameReverse()
main()
最佳答案
如果是python 2.x,则应使用
name = str(raw_input("Enter your full name: "))
完整代码:
def nameReverse():
name = str(raw_input("Enter your full name: "))
testName = name.split()
if len(testName)>1:
firstName=testName[0]
lastName=testName[1]
print (lastName,firstName)
def main():
nameReverse()
main()
关于python - Python : Unknown Invalid Syntax Error,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46647377/