An Interest In:
Web News this Week
- March 19, 2024
- March 18, 2024
- March 17, 2024
- March 16, 2024
- March 15, 2024
- March 14, 2024
- March 13, 2024
January 19, 2022 10:47 pm GMT
Original Link: https://dev.to/mahmoudessam/python-challenge14-35g8
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)
My Solution
def up_down(number): down = number - 1 up = down + 2 return (down, up)
Another Solution
def up_down(x): return (x-1, x+1)
All the best to you.
Original Link: https://dev.to/mahmoudessam/python-challenge14-35g8
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To