Home > Net >  TypeError: 'list' object is not callable python
TypeError: 'list' object is not callable python

Time:09-30

how can I fix this error in this code?

while True:
    input1 = input("Hello >> ")

    input = input1.split()

    if input[0] == "Sup":
        print("HI!")

Error:

input1 = input("Hello >> ")
TypeError: 'list' object is not callable

CodePudding user response:

Don't use input as a variable name. Change your code to something like this:

while True:
    input1 = input("Hello >> ")

    userInput = input1.split()

    if userInput[0] == "Sup":
        print("HI!")

CodePudding user response:

input = input1.split()

You're reassigning input to be a list value, and it isn't a function anymore.

  • Related