Medium
Refactor Legacy Python Code
Improve the efficiency and readability of a provided Python code snippet by applying Pythonic idioms.
📝 Conteúdo do Prompt
You are an expert Python developer. Please review the following code snippet. Identify any performance bottlenecks, readability issues, or anti-patterns. Refactor the code to be more efficient using Pythonic idioms, add docstrings where necessary, and explain the changes you made in a list format. Code snippet: def get_primes(n): primes = [] for num in range(2, n + 1): for i in range(2, num): if (num % i) == 0: break else: primes.append(num) return primes