input: Write a function to create a simple chatbot using Python and state diagrams. The function should initialize states with messages and replies, and it should maintain a conversation recording and update the current state based on user input. If the user input is not recognized, the function should display a default message and prompt the user to try again. Upon reaching a terminal state (a state with no replies), the function should end the conversation.
  assert chatbot()==None
  assert chatbot().states=={'state0': {'name': 'state0', 'message': 'Hello! How can I help you?', 'replies': {'I need some advice': 'state1', 'Can you answer my questions?': 'state2'}}, 'state1': {'name': 'state1', 'message': 'Sure, what kind of advice do you need?', 'replies': {'Career advice': 'state3', 'Health advice': 'state4'}}, 'state2': {'name': 'state2', 'message': 'Yes, I'll do my best! What do you want to know?', 'replies': {'Where can I find good tutorials': 'state5', 'Why is coding so hard': 'state6'}}, 'state3': {'name': 'state3', 'message': 'It is always a good idea to research the field you are interested in and creating a plan to learn the skills that are required. Make sure to contact professionals in the field to understand their experience.', 'replies': {}}, 'state4': {'name': 'state4', 'message': 'Focus on eating healthy and staying active. Make sure to consult a medical professional if you have any concerns.', 'replies': {}}, 'state5': {'name': 'state5', 'message': 'You can find tutorials online or join coding communities to get help from experienced coders. StackOverflow and Cod Academy are great resources.', 'replies': {}}, 'state6': {'name': 'state6', 'message': 'Coding can be challenging, especially at first. Just remember that with practice, patience and problem solving skills you can overcome the obstacles.', 'replies': {}}}
  assert chatbot().current_state=='state0'
  assert chatbot().conversation==[]
output: def chatbot():
      class Chatbot:
          def __init__(self):
              self.states = {
                  'state0': {'name': 'state0', 'message': 'Hello! How can I help you?', 'replies': {'I need some advice': 'state1', 'Can you answer my questions?': 'state2'}},
                  'state1': {'name': 'state1', 'message': 'Sure, what kind of advice do you need?', 'replies': {'Career advice': 'state3', 'Health advice': 'state4'}},
                  'state2': {'name': 'state2', 'message': 'Yes, I\'ll do my best! What do you want to know?', 'replies': {'Where can I find good tutorials': 'state5', 'Why is coding so hard': 'state6'}},
                  'state3': {'name': 'state3', 'message': 'It is always a good idea to research the field you are interested in and creating a plan to learn the skills that are required. Make sure to contact professionals in the field to understand their experience.', 'replies': {}},
                  'state4': {'name': 'state4', 'message': 'Focus on eating healthy and staying active. Make sure to consult a medical professional if you have any concerns.', 'replies': {}},
                  'state5': {'name': 'state5', 'message': 'You can find tutorials online or join coding communities to get help from experienced coders. StackOverflow and Cod Academy are great resources.', 'replies': {}},
                  'state6': {'name': 'state6', 'message': 'Coding can be challenging, especially at first. Just remember that with practice, patience and problem solving skills you can overcome the obstacles.', 'replies': {}}
              }
              self.current_state = 'state0'
              self.conversation = []
  
          def run(self):
              while self.states[self.current_state]['replies']:
                  message = self.states[self.current_state]['message']
                  self.conversation.append(message)
                  user_input = input(message + " ")
                  if user_input in self.states[self.current_state]['replies']:
                      self.current_state = self.states[self.current_state]['replies'][user_input]
                  else:
                      self.conversation.append("Sorry, I didn't understand that. Please try again.")
              self.conversation.append(self.states[self.current_state]['message'])
              return None
  
      bot = Chatbot()
      bot.run()
      return bot