I'm trying to make a pattern in HackerRank and as far as I can tell, my solution works.
size = int(input())
letters = 'abcdefghijklmnopqrstuvwxyz'
for i in range(size):
textp = "-".join(letters[size - 1: size - (1 + i): -1])
textn = "-".join(letters[size - i: size: 1])
print(textp.rjust(size + 2, '-') + '-' + letters[size - (1 + i)] + '-' + textn.ljust(size + 2, '-'))
for i in range(size - 2, -1, -1):
textp = "-".join(letters[size - 1: size - (1 + i): -1])
textn = "-".join(letters[size - i: size: 1])
print(textp.rjust(size + 2, '-') + '-' + letters[size - (1 + i)] + '-' + textn.ljust(size + 2, '-'))
prints out:
--------e--------
------e-d-e------
----e-d-c-d-e----
--e-d-c-b-c-d-e--
e-d-c-b-a-b-c-d-e
--e-d-c-b-c-d-e--
----e-d-c-d-e----
------e-d-e------
--------e--------
But when I try to submit it I get
File "solution.py", line 12, in <module>
n = int(input())
EOFError: EOF when reading a line
I'm new to python so I'm not sure how to resolve this error. The code works fine and I don't understand why the input() function is messing up.