python 3.x - IDLE returning syntax errors for no reason that I can discern -
# function starts_with() - finds if list 1 starts list 2 : ) def starts_with(list1, list2): count = 0 if length (list1) >= length(list2):(error) var in range(length(list2):(error) if var == list2[var]: (error) count(error) += 1 else: return false if count = length(list2): return true else: return false
this code returns syntax errors @ marked points. length same thing len, , realize horrible programmer.
after removing (error)
markers, there two actual syntax errors in script:
- missing closing parens
)
infor var in range(length(list2):
- assignment
=
instead of equality check==
inif count = length(list2):
apart that, there other issues, not syntax errors:
- should
length
len
? if have function calledlength
, same thinglen
, why not uselen
in first place? - unless defined "aliases" those, too,
true
,false
shouldtrue
,false
for other places, can't see what's wrong there, might follow-up errors resolved once fix other ones. if not fix it:
- check indentation; make sure use tabs or spaces, not mixture
- post actual syntax error getting
Comments
Post a Comment