Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize the variable 'feature' from the variable 'features' only when the answer is non-empty #241

Conversation

jacky18008
Copy link
Contributor

Because the empty answer ( which will occur when 'version_2_with_negative' is set to True) has an empty 'features', the previous code will meet a 'list out of index' error for trying indexing on an empty list.

Therefore, initialize the 'feature' by 'features' only when the 'pred.start_index' is greater than 0 can simply fix it. (pred.start_index > 0 means the answer is not empty.)

Moreover, for we do not need the variable 'feature' while the answer is empty, it's OK to do so.

…mptiness of answer is checked, while empty answer has no feature
…mptiness of answer is checked, while empty answer has empty features
@ThilinaRajapakse ThilinaRajapakse merged commit 1637651 into ThilinaRajapakse:master Mar 2, 2020
@ThilinaRajapakse
Copy link
Owner

@all-contributors please add @jacky18008 for code

@allcontributors
Copy link
Contributor

@ThilinaRajapakse

I've put up a pull request to add @jacky18008! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants