When I upload the python file to codePost.io, I get an error that says "EOF Error when reading a line". I tried to use "try and except" method but in this case I get an AttributeError. What should I do? Here is my code:
try:
rows = int(input("Enter a number of rows: "))
columns = int(input("Enter a number of columns: "))
def print_rect(row, col):
for r in range(1, row + 1):
for i in range(1, col + 1):
if r == 1 or r == row or i == 1 or i == col:
print("*", end="")
else:
print(" ", end="")
print()
print_rect(rows, columns)
except EOFError:
pass
Try this please:
try:
print("Enter a number of rows:")
rows = int(input())
print("Enter a number of columns:")
columns = int(input())
def print_rect(row, col):
for r in range(1, row + 1):
for i in range(1, col + 1):
if r == 1 or r == row or i == 1 or i == col:
print("*", end="")
else:
print(" ", end="")
print()
print_rect(rows, columns)
except EOFError:
pass
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.