Skip to content
The Chat Archive
gpt-4o-2024-08-06· OpenAI WildChat-4.8M (AI2)

Fix errors and bugs in the given code, without changing its intended functionality. ONLY…

  1. User

    Fix errors and bugs in the given code, without changing its intended functionality. ONLY return the fixed code and nothing else. Enclose the entire code in a single code block.

    gpt-4o (default)

  2. Assistant
    def calculate_average(numbers):
        if not numbers:
            return 0
        return sum(numbers) / len(numbers)
    
    def print_positive_numbers(numbers):
        positive_numbers = [num for num in numbers if num > 0]
        for num in positive_numbers:
            print(num)
    
    def main():
        numbers = [1, -2, 3, 4, -5, 6]
        avg = calculate_average(numbers)
        print(f"Average of numbers: {avg}")
        print("Positive numbers:")
        print_positive_numbers(numbers)
    
    if __name__ == '__main__':
        main()