Cannot figure out what is causing this error in Python

Question:

I keep getting this TypeError: ‘int’ object is not subscriptable error. I’m stuck.

enter image description here

I’ve tried taking away and adding str and int in different places but nothing has worked at all.

Asked By: Timothy Carroll

||

Answers:

Try this code.

def midform(point1, point2):
    x = (point1[0] + point2[0])/2
    y = (point1[1] + point2[1])/2
    print("Midpoint X:", x, "Y:", y)

Error: because point1[0] is in your case an integer and you try indexing on int.

Answered By: codester_09
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.