def analyze_code(state: dict) -> dict:
    """
    Analyzes the provided code snippet and returns a suggestion for improvement.
    """
    if "for i in range(len(" in state['code_snippet']:
        state['suggestion'] = "Consider using enumerate() for better readability."
    else:
        state['suggestion'] = "Code snippet looks good."
    return state


import unittest


class TestAnalyzeCodeNode(unittest.TestCase):

    def test_suggestion_with_for_loop(self):
        # Test case where the agent should suggest using enumerate
        state = {"code_snippet": "for i in range(len(arr)): print(arr[i])", "suggestion": ""}
        expected_suggestion = "Consider using enumerate() for better readability."

        result = analyze_code(state)
        self.assertEqual(result['suggestion'], expected_suggestion)

    def test_suggestion_no_improvement_needed(self):
        # Test case where no improvements are necessary
        state = {"code_snippet": "print('Hello, World!')", "suggestion": ""}
        expected_suggestion = "Code snippet looks good."

        result = analyze_code(state)
        self.assertEqual(result['suggestion'], expected_suggestion)


if __name__ == '__main__':
    unittest.main()
