Ask coding questions

← Back to all posts
TypeError: 'int' object is not subscriptable
CodingMEJ (10)

So im trying to make connect 4 for a class and its giving me this error try doing 4,4,4,4 as the input and it will give you and error can anyone help me out
BTW IM NOT DONE SO DONT TELL ME IT DOESNT LOOK GOOD also it should say true at the bottom when and if you get it four in a row(I HAVENT DONE DIAGNOL YET!)


everything seems to be working.

Coder100 (16857)

of course, 4,4,4 is not a number.

CodingMEJ (10)

@Coder100 I know i figured it out but now i have another problem if you do 7 it will give you a range error anyway to help me this time?

Coder100 (16857)

@CodingMEJ it is over the length of the array. That is why.

Coder100 (16857)

@CodingMEJ so basically have a check like this:

if userColumn > len(a):
  # do something
  # safely do code
CodingMEJ (10)

@Coder100 Im still confused anyway you could help me more