DEV Community

Cover image for Python challenge_14
Mahmoud EL-kariouny
Mahmoud EL-kariouny

Posted on

Python challenge_14

Up and down

simple challenge

Define a function named up_down that takes a single number
As its parameter.

Your function return a tuple containing two numbers
The first should be one lower than the parameter,
And the second should be one higher.

For example:

calling up_down(5) should return (4, 6)
Enter fullscreen mode Exit fullscreen mode

My Solution

def up_down(number):
    down = number - 1
    up = down + 2
    return (down, up)
Enter fullscreen mode Exit fullscreen mode

Another Solution

def up_down(x):
    return (x-1, x+1)
Enter fullscreen mode Exit fullscreen mode

All the best to you.

Top comments (0)