columns = input("Enter number of columns: ")
rows = input("Enter number of rows: ")
for r in range(rows):
if r == 0 or r == rows - 1:
print('* ' * columns)
else:
print('* ' + ' ' * (columns - 2) + '* ')
How to create a rectangle pattern using Python : What's wrong with my code
195 views Asked by Musa Dladla At
1
You have maybe used languages as
C/C++, in which you do something like:But in Python you have to do a
casting, like this......before using it as an integer.