I can't find why this piece of code won't work:
class Agent:
def hello(self, first_name):
return "Bien le bonjour" + first_name + "!"
agent = Agent()
print(agent.hello("Félix"))
I'm pretty sure to run it under python3 since i just follow a tutorial on how to create a local envirement for python3.
It return
class Agent:
File "la_poo_avec_python-00_setup/model.py", line 4, in Agent
agent = Agent()
NameError: name 'Agent' is not defined
(my_env) noob@Flex:~/Noobi/prog/python3env/my_env$
Your code is correct, but I suspect there is something wrong with the indentation. This is how it should be
class Agent:
def hello(self, first_name):
return "Bien le bonjour" + first_name + "!"
agent = Agent()
print(agent.hello("Félix"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With