← Back to challenges

Convert Number to String of Dashes

PythonMediumloopsstringsnumbers

Instructions

Create a function that takes a number (from 1 - 60) and returns a corresponding string of hyphens.

Examples

num_to_dashes(1) ➞ "-"

num_to_dashes(5) ➞ "-----"

num_to_dashes(3) ➞ "---"

Notes

  • You will be provided integers ranging from 1 to 60.
  • Don't forget to return your result as a string.
  • If you get stuck on a challenge, find help in the Resources tab.
  • If you're really stuck, unlock solutions in the Solutions tab.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: I'd Like a New Shade of Blue, Please