Create a diagonal line given its length (let’s call the variable, say, \$n\$ where \$n > 0\$)
- The diagonal line starts from the top left and goes to the bottom right.
- You must use the ASCII character
\for the line.
- The input number can be given from STDIN or if your program doesn’t support that, use a hardcoded value in your code or pass it as an argument while running the program.
- For padding, only use the space character
- Trailing spaces and/or newlines are allowed.
- The length of the line is the non whitespace characters
Here is an example program (59 bytes):
n = int(input()) for i in range(n): print(' ' * i + '\\')
Input: 4 Output \ \ \ \
- Use standard I/O when possible.
- Standard loopholes are forbidden.
- This is code golf, so the shortest answer in bytes wins.
- Please explain the code that you wrote.