import click
from tabulate import tabulate

from EasyEuler import data


@click.command()
@click.option('--sort', '-s', type=click.Choice(['id', 'difficulty']),
              default='id', help='Sort the list by problem attribute.')
def cli(sort):
    """ Lists all available problems. """

    problems = sorted(data.problems, key=lambda p: p[sort.lower()])
    problem_list = [(problem['id'], problem['name'], problem['difficulty'])
                    for problem in problems]

    problem_table = tabulate(problem_list, ['ID', 'Name', 'Difficulty'],
                             tablefmt='fancy_grid')
    click.echo_via_pager(problem_table)

import click
from tabulate import tabulate

from EasyEuler import data


@click.command()
@click.option('--sort', '-s', type=click.Choice(['id', 'difficulty']),
              default='id', help='Sort the list by problem attribute.')
def cli(sort):
    """ Lists all available problems. """

    problems = sorted(data.problems, key=lambda p: p[sort.lower()])
    problem_list = [(problem['id'], problem['name'],
                     '%d%%' % problem['difficulty']) for problem in problems]

    problem_table = tabulate(problem_list, ['ID', 'Name', 'Difficulty'],
                             tablefmt='fancy_grid')
    click.echo_via_pager(problem_table)

Add percentage sign to difficulty
Add percentage sign to difficulty

  import click
  from tabulate import tabulate
  
  from EasyEuler import data
  
  
  @click.command()
  @click.option('--sort', '-s', type=click.Choice(['id', 'difficulty']),
                default='id', help='Sort the list by problem attribute.')
  def cli(sort):
      """ Lists all available problems. """
  
      problems = sorted(data.problems, key=lambda p: p[sort.lower()])
-     problem_list = [(problem['id'], problem['name'], problem['difficulty'])
+     problem_list = [(problem['id'], problem['name'],
-                     for problem in problems]
+                      '%d%%' % problem['difficulty']) for problem in problems]
  
      problem_table = tabulate(problem_list, ['ID', 'Name', 'Difficulty'],
                               tablefmt='fancy_grid')
      click.echo_via_pager(problem_table)
  
Add percentage sign to difficulty
## Code Before:
import click
from tabulate import tabulate

from EasyEuler import data


@click.command()
@click.option('--sort', '-s', type=click.Choice(['id', 'difficulty']),
              default='id', help='Sort the list by problem attribute.')
def cli(sort):
    """ Lists all available problems. """

    problems = sorted(data.problems, key=lambda p: p[sort.lower()])
    problem_list = [(problem['id'], problem['name'], problem['difficulty'])
                    for problem in problems]

    problem_table = tabulate(problem_list, ['ID', 'Name', 'Difficulty'],
                             tablefmt='fancy_grid')
    click.echo_via_pager(problem_table)

## Instruction:
Add percentage sign to difficulty
## Code After:
import click
from tabulate import tabulate

from EasyEuler import data


@click.command()
@click.option('--sort', '-s', type=click.Choice(['id', 'difficulty']),
              default='id', help='Sort the list by problem attribute.')
def cli(sort):
    """ Lists all available problems. """

    problems = sorted(data.problems, key=lambda p: p[sort.lower()])
    problem_list = [(problem['id'], problem['name'],
                     '%d%%' % problem['difficulty']) for problem in problems]

    problem_table = tabulate(problem_list, ['ID', 'Name', 'Difficulty'],
                             tablefmt='fancy_grid')
    click.echo_via_pager(problem_table)
