Reputation: 15
How to assign a default value?
r=int(input('Number of rows?: '))
c=int(input('Number of Columns?: '))
w=int(input('Width of a column'))
h=int(input('Height of a row'))
row= (('+')+ w*('-')+('+'))* (c)
width= (('-') * w)*c
col=(('+')+ w*('-')+('+'))
height=(('|')+ w * (' ')+ ('|'))* c
c=square brackets with zero in it
for i in range(r):
print(row)
print(height)
c.append(col)
print(c* square brackets having zero)
But it's not working...[The question is displayed on the uploaded below image ] https://i.sstatic.net/JLQ8i.jpg
Upvotes: 1
Views: 178
Reputation: 2743
Here's my best guess as to what you're trying to do:
r = int(input('Number of rows?: ') or 4)
c = int(input('Number of Columns?: ') or 4)
w = int(input('Width of a column') or 4)
h = int(input('Height of a row') or 4)
row = (('+') + w * ('-')) * (c) + '+'
width= (('-') * w) * c
col = (('+') + w * ('-') + ('+'))
height = (('|') + w * (' ')) * c + '|'
#c=square brackets with zero in it
for i in range(r):
print(row)
for j in range(h):
print(height)
print(row)
#c.append(col)
#print(c* square brackets having zero)
And a sample run:
Number of rows?: 3
Number of Columns?: 4
Width of a column5
Height of a row6
+-----+-----+-----+-----+
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
+-----+-----+-----+-----+
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
+-----+-----+-----+-----+
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
+-----+-----+-----+-----+
Perhaps you could provide some sample output and clarify what you're trying to do with c
.
Upvotes: 1