请通过以下代码为我提供帮助,
N = int(input())
print("Enter number",N)
if(N%2!=0):
print("Weird")
elif (N%2==0) and (N>=2 and N<=5):
print("Not Weird")
elif(N%2==0) and (N>=6 and N<=20):
print("Weird")
else:
print("Not Weird")
我遇到以下错误:
File "solution.py", line 7
elif (N%2==0) and (N>=2 and N<=5):
^
SyntaxError: invalid syntax
请帮助我解决此错误,谢谢
答案 0 :(得分:1)
问题在于缩进。
N = int(input())
print("Enter number",N)
if(N%2!=0):
print("Weird")
elif (N%2==0) and (N>=2 and N<=5):
print("Not Weird")
elif(N%2==0) and (N>=6 and N<=20):
print("Weird")
else:
print("Not Weird")
答案 1 :(得分:0)
基于缩进,如果没有RewriteEngine On
RewriteCond %{HTTP_HOST} ^client-domain.in [NC]
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI}/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^mydomain.in [NC]
RewriteRule ^(.*)$ http://%{SERVER_NAME}%{REQUEST_URI}/$1 [L,R=301]
,则无法启动elif
,应始终先启动if
,然后再启动if
。您可以检查以下情况:
elif
对于您的编码约定,您始终可以查看PEP 8 -- Style Guide for Python Code