1

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

1
  • What uploaded image? Commented Oct 3, 2015 at 20:03

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.