mercredi 3 juin 2015

How come would I get a invalid syntax error using this simple if statement in Python 2.7? [on hold]

Here is my code:

def substringRemove(self, src_str, begin_index, end_index):
    if (begin_index <= 0) or (begin_index > end_index) or (end_index >= len(src_str)):
        sys.exit("String index error")
    else:
        return src_str[:begin_index]+src_str[end_index:]

I run this code in Python2.7 and get error info:

if (begin_index <= 0) or (begin_index > end_index) or (end_index <= len(src_str)):
^
SyntaxError: invalid syntax

I can not figure it out...

Aucun commentaire:

Enregistrer un commentaire