+ 2
What is invalid syntax in this code
5 Réponses
+ 7
Rahul Kanade ,
your code has a poor formatting, specially for the indentation (using only 1 space per indentation level has a bad readability).
> use 4 spaces for each indentation level as it is recommended in the python python style guide
+ 6
#read comments... What is your task by this?
w = input()
v = len(w)
print(v)
i = 0
for g in w:
i<v # no effect statement
if g[i] in g[i+1:] and i+1 < v:
print("false")
break
elif : #condition is missing , also wrong indentation
i+1=v # wrong way : do v = i+1 left side should be variable
print("true")
break
else:
print("true")
break
+ 4
You are using one equal (=) sign in elif, you need to use 'double equals' (==) for comparision
change, (line 12)
-> i+1=v
to
-> i+1 == v
Also, Fix the formatting, do it as suggested by Lothar and Jayakrishna
(to fix problem: delete one space in line 12)
+ 4
elif: is invlid syntax. Condition missing.
Rahul Kanade You may trying,
elif i+1 == v : #correct way
+ 1
I just want to know why it is showing invalid syntax in elif statement