in the following program I got the index out of range error:
def evaluate(x, y):
result = 0
for i in x:
result += (x[i])*(y**i)
return result
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You are already looping over all values of
x, no need to then index them again:Compare the following two:
If you expected
ito be an index intox, useenumerate()to get that index: