'trying to create a chat "template" for my chatbot [closed]

I am trying to create a template for my chat bot so the chat looks like

carl: my name is carl, what is yours?

user: *some response*

I have no issues with the bot template, but where my issue is coming by is when I try to create the users template, it gives me an error saying "TypeError: unsupported operand type(s) for +: 'function' and 'str'"

# templates
def templates():
    user = myname
    print(user + ':')

# asking your name
def myname():
    print('carl: my name is carl, what is yours?')
    myname = input()
    templates()
    print('carl: nice to meet you ' + myname)

if anyone has any advice, would be greatly appreciated



Solution 1:[1]

Try this:

def templates(user):
    print(user + ': *some response*')

def myname():
    print('carl: my name is carl, what is yours?')
    user = input()
    templates(user)
    print('carl: nice to meet you ' + user)

myname()

Your problem is that you make a function called myname and also make a variable called myname, among other things.

Solution 2:[2]

NEVER! EVER! Use the a variable name as a function name. Just change the variable name to UsersName = input();

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 wjmolina
Solution 2