← Back to challenges

Smaller String Number

PythonHardstringslanguage_fundamentals

Instructions

Create a function that returns the smaller number.

Examples

smaller_num("21", "44") ➞ "21"

smaller_num("1500", "1") ➞ "1"

smaller_num("5", "5") ➞ "5"

Notes

  • Numbers will be represented as strings, and your output should also be a string.
  • If both numbers tie, return either number.
  • Numbers will be positive.
  • Bonus: See if you can do this without converting to integers.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Rounding in Millions