DEV Community

Cover image for Python ๐Ÿ challenge_23โš”๏ธ
Mahmoud EL-kariouny
Mahmoud EL-kariouny

Posted on โ€ข Edited on

1

Python ๐Ÿ challenge_23โš”๏ธ

Highest and Lowest

  • In this little assignment you are given a string of space separated numbers.
  • And have to return the highest and lowest number.

Examples:

high_and_low("1 2 3 4 5")  # return "5 1"
high_and_low("1 2 -3 4 5") # return "5 -3"
high_and_low("1 9 3 4 -5") # return "9 -5"

Enter fullscreen mode Exit fullscreen mode

Notes:

  • All numbers are valid Int32, no need to validate them.
  • There will always be at least one number in the input string.
  • Output string must be two numbers separated by a single space, And highest number is first.
Task URL: Link

My Solution:

def high_and_low(numbers: str) -> str:

    high: str = str(max([int(number) for number in numbers.split()]))
    low: str = str(min([int(number) for number in numbers.split()]))
    return f"The highest number in the lest: {high} The lowest number in the lest: {low}"

Enter fullscreen mode Exit fullscreen mode

Learn Python

Python top free courses from Coursera๐Ÿ๐Ÿ’ฏ๐Ÿš€

๐ŸŽฅ

Connect with Me ๐Ÿ˜Š

๐Ÿ”— Links

linkedin

twitter

Image of Datadog

The Future of AI, LLMs, and Observability on Google Cloud

Datadog sat down with Googleโ€™s Director of AI to discuss the current and future states of AI, ML, and LLMs on Google Cloud. Discover 7 key insights for technical leaders, covering everything from upskilling teams to observability best practices

Learn More

Top comments (0)

Sentry image

See why 4M developers consider Sentry, โ€œnot bad.โ€

Fixing code doesnโ€™t have to be the worst part of your day. Learn how Sentry can help.

Learn more