Skip to main content
 首页 » 编程设计

python之第 8 行 : SyntaxError之bad input (' ' )

2025年05月04日13dyllove98

<分区>

为什么上面那个不行,下面那个还好呢?我认为这是空间问题,但它看起来相同。有什么问题?

损坏的代码:

month = int(input("Enter the month: ")) 
day = int(input("Enter the day: ")) 
 
if (month == 9): 
    if (day <= 15): 
     print ("First half of the month") 
    else: 
     print ("Second half of the month") #The line with the error 
else: 
 print ("Not in September") 

工作代码:

month = int(input("Enter the month: ")) 
day = int(input("Enter the day: ")) 
 
if (month == 9): 
    if (day <= 15): 
     print ("First half of the month") 
    else: 
     print ("Second half of the month") 
else: 
 print ("Not in September")