Simple kata, simple rules: your function should accept the inputs 4
and 7
. If 4
is entered, the function should return 7
. If 7
is entered, the function should return 4
. Anything else entered as input should return a false-y value such as False
, 0
, []
, ""
. There's only one catch, your function cannot include if statements (or the eval function due to the fact that you can get around the if requirement using it).
There are some very simple ways of answering this problem, but I encourage you to try and be as creative as possible.
Good Luck!
def solution(n):
pass
def solution(n):
nums = {4: 7, 7:4}
return nums.get(n, False)