def sum_of_multiples(limit, factors):
    return sum(all_multiples(limit, factors))


def all_multiples(limit, factors):
    multiples = set()
    for factor in factors:
        multiples = multiples.union(get_multiples(limit, factor))
    return multiples

def get_multiples(limit, factor):
    if factor == 0:
        return []

    multiples = set()
    for i in range(0, limit):
        if i % factor == 0:
            multiples.add(i)
    return multiples


def sum_of_multiples(limit, factors):
    return sum(all_multiples(limit, factors))


def all_multiples(limit, factors):
    multiples = set()
    for factor in factors:
        multiples = multiples.union(get_multiples(limit, factor))
    return multiples

def get_multiples(limit, factor):
    if factor == 0:
        return []

    return [multiple for multiple in range(limit) if multiple % factor == 0]


Refactor to use list comprehension
Refactor to use list comprehension

  def sum_of_multiples(limit, factors):
      return sum(all_multiples(limit, factors))
  
  
  def all_multiples(limit, factors):
      multiples = set()
      for factor in factors:
          multiples = multiples.union(get_multiples(limit, factor))
      return multiples
  
  def get_multiples(limit, factor):
      if factor == 0:
          return []
  
+     return [multiple for multiple in range(limit) if multiple % factor == 0]
-     multiples = set()
-     for i in range(0, limit):
-         if i % factor == 0:
-             multiples.add(i)
-     return multiples
  
  
Refactor to use list comprehension
## Code Before:
def sum_of_multiples(limit, factors):
    return sum(all_multiples(limit, factors))


def all_multiples(limit, factors):
    multiples = set()
    for factor in factors:
        multiples = multiples.union(get_multiples(limit, factor))
    return multiples

def get_multiples(limit, factor):
    if factor == 0:
        return []

    multiples = set()
    for i in range(0, limit):
        if i % factor == 0:
            multiples.add(i)
    return multiples


## Instruction:
Refactor to use list comprehension
## Code After:
def sum_of_multiples(limit, factors):
    return sum(all_multiples(limit, factors))


def all_multiples(limit, factors):
    multiples = set()
    for factor in factors:
        multiples = multiples.union(get_multiples(limit, factor))
    return multiples

def get_multiples(limit, factor):
    if factor == 0:
        return []

    return [multiple for multiple in range(limit) if multiple % factor == 0]

