使用print时语法错误无效

时间:2013-11-14 19:00:15

标签: python printing

我收到错误

invalid syntax

当我运行以下代码时:

print("Hello how old are you?(years)"
print ("(1) 0-10")      
print ("(2) 11-20")
print ("(3) 21-30")
print ("(4) 31-40")
print ("(5) 41-50")
print ("(6) 51-60")
print ("(7) 61-70")
print ("(8) 71-80")
print ("(9) 81-90")
print ("(10)90+")
  c=input
  if int(c)==1
print ("")

在这一行

print ("(1) 0-10")

它表示print是一种无效的语法,如果我删除该行,它会移动到下一行,依此类推。我能在这里得到一些帮助吗?谢谢!

1 个答案:

答案 0 :(得分:8)

print("Hello how old are you?(years)") # <== missing this )

您接下来的语法错误可能如下:

c=input() # <== missing ()

if int(c)==1: # <== missing :
    print ("") # missing indentation  

只要你得到那种行为if i delete that line it moves on to the next, and so on.,这可能意味着语法错误不在该行而是在它之前的行。