Click here to Skip to main content
14,981,622 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
this is the code

print(input("Choose a tile: "))

white = ["y1", "y5", "y9", "d1"]
black = ["z1", "y8", "d2", "f2"]

if input[list]:

if input[list2]:

this is the error i keep getting

TypeError: 'builtin_function_or_method' object is not subscriptable

What I have tried:

i've tried every solution i saw on google
Updated 30-Jan-21 2:36am

input is a method: you call it using round brackets and it returns a value: Python input() Function[^]
Square brackets are for lists and indexing, as in this example: 6.3. Index Operator: Working with the Characters of a String — Foundations of Python Programming[^]
I did tell you yesterday in your previous post of this question (How do I get rid of this syntax error in Python 3.8[^]) that that code makes no sense.
1. print(input("Choose a tile: ")) 

2. white = ["y1", "y5", "y9", "d1"]
black = ["z1", "y8", "d2", "f2"]

3. if input[list]:
4. print("white")

if input[list2]:

1. You call the input function to get information from the user, but just print it out, without saving it anywhere.
2. You create two lists of strings: not sure what they are for.
3. You cannot use the input statement like that. The input function posts a message to the terminal and waits for input from the user. Also, the if clause has nothing to compare against.
4. Will print the string "white", but I am not sure that is what you want.

I strongly suggest you go to The Python Tutorial — Python 3.7.9 documentation[^]
and learn the language thoroughly.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900