Skip to content

Instantly share code, notes, and snippets.

@serashioda
Last active December 18, 2016 02:06
Show Gist options
  • Save serashioda/8ea5dad97c12a0ac5fc310e39ed71869 to your computer and use it in GitHub Desktop.
Save serashioda/8ea5dad97c12a0ac5fc310e39ed71869 to your computer and use it in GitHub Desktop.
"""Implementation of the add_me module."""
def add_me(num_lst, sing_digit):
"""returns sum of list of nums as a whole num and adds single dig."""
num_sum = int(''.join(map(str, num_lst)))
result = num_sum + sing_digit
return result
"""Test for add_me function."""
import pytest
TEST_TABLE = [
[([1, 2, 3, 4], 1), 1235],
[([1, 2, 3, 4], -1) 1233]
]
@pytest.mark.parametrize("num_lst, sing_digit, result", TEST_TABLE)
def test_add_me(num_lst, sing_digit, result, Test_TABLE)
"""Test the add_me function."""
from add_me import add_me
assert add_me(num_lst, sing_digit) == result
Write a function that takes as arguments:
- a list of integers that represents a whole number
--> ex: [1, 2, 3 ,4] = 1234
--> ex: [8, 2] = 82
- a single-digit integer (-9, 9)
Return the sum of the whole-number version of the
list of numbers, and that single-digit integer, as a list
add_me([1, 2, 3, 4], 1) --> [1, 2, 3, 5]
@Bl41r
Copy link

Bl41r commented Dec 18, 2016

Halfway there! Just make sure to relax and read the problem carefully. I hold off coding for at least 5 minutes on gists and just think about the problem. See if you can go back and get the second half of this (returning the list).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment