from django import template

register = template.Library()


@register.filter
def get_range(value):
    return range(value)


@register.filter
def absolute(value):
    return abs(value)


@register.filter
def subtract(value, arg):
    return value - arg


@register.filter
def multiply(value, arg):
    return value * arg


@register.filter
def remove_extension(string):
    return string.replace('.png', '').replace("'", "").replace('(', '_').replace(')', '_')

from django import template

register = template.Library()


@register.filter
def get_range(value):
    if value:
        return range(value)
    else:
        return 0


@register.filter
def absolute(value):
    return abs(value)


@register.filter
def subtract(value, arg):
    return value - arg


@register.filter
def multiply(value, arg):
    return value * arg


@register.filter
def remove_extension(string):
    return string.replace('.png', '').replace("'", "").replace('(', '_').replace(')', '_')

Return 0 with the get_range filter if value is invalid instead of raise exception
Return 0 with the get_range filter if value is invalid instead of raise exception

  from django import template
  
  register = template.Library()
  
  
  @register.filter
  def get_range(value):
+     if value:
-     return range(value)
+         return range(value)
+     else:
+         return 0
  
  
  @register.filter
  def absolute(value):
      return abs(value)
  
  
  @register.filter
  def subtract(value, arg):
      return value - arg
  
  
  @register.filter
  def multiply(value, arg):
      return value * arg
  
  
  @register.filter
  def remove_extension(string):
      return string.replace('.png', '').replace("'", "").replace('(', '_').replace(')', '_')
  
Return 0 with the get_range filter if value is invalid instead of raise exception
## Code Before:
from django import template

register = template.Library()


@register.filter
def get_range(value):
    return range(value)


@register.filter
def absolute(value):
    return abs(value)


@register.filter
def subtract(value, arg):
    return value - arg


@register.filter
def multiply(value, arg):
    return value * arg


@register.filter
def remove_extension(string):
    return string.replace('.png', '').replace("'", "").replace('(', '_').replace(')', '_')

## Instruction:
Return 0 with the get_range filter if value is invalid instead of raise exception
## Code After:
from django import template

register = template.Library()


@register.filter
def get_range(value):
    if value:
        return range(value)
    else:
        return 0


@register.filter
def absolute(value):
    return abs(value)


@register.filter
def subtract(value, arg):
    return value - arg


@register.filter
def multiply(value, arg):
    return value * arg


@register.filter
def remove_extension(string):
    return string.replace('.png', '').replace("'", "").replace('(', '_').replace(')', '_')
