0

can someone guide me printing this . pls(I dont want the exact solution , want to do this myself but need help)

# # # # # # # # # # # # # # # # # # # # # # # #

11th Nov 2018, 3:43 PM
partha
partha - avatar
7 odpowiedzi
+ 6
What have you got so far? And do you want a size determined by input?
11th Nov 2018, 4:13 PM
Paul
Paul - avatar
+ 3
No problem.. That's what we are here for. There are probably people here who can do it better, more efficient, and with less lines. Usually is lol.
20th Nov 2018, 9:57 PM
LordHill
LordHill - avatar
+ 2
It's been long enough, this is how I would do it... num=int(input()) for i in range(num): if i==0 or i==num-1: print("#"*(num+2)) else: print("#"+" "*num+"#")
17th Nov 2018, 7:37 PM
LordHill
LordHill - avatar
+ 1
You could use string formatting several different ways to create that output. str.format() will allow you to access by position, specify the width, and align the text. You could print each line separately or create a single string that is only printed once.
11th Nov 2018, 5:05 PM
Joshua Starner
Joshua Starner - avatar
+ 1
I would use a for loop. for my first and last runs of the loop I would print "#" * n .. with n being the number of those I wanted. every other run of the loop I would have print one # , add " " * (n-2) , and add another #
11th Nov 2018, 6:00 PM
LordHill
LordHill - avatar
+ 1
hey Rick Morty thanks a lot I was absent here coz my exams were going on. I tried implementing your idea but couldn't and you helped me again by giving the solution ^_^
20th Nov 2018, 2:49 PM
partha
partha - avatar
0
Thanks
17th Nov 2018, 7:18 PM
Nayan