0
can someone guide me printing this . pls(I dont want the exact solution , want to do this myself but need help)
# # # # # # # # # # # # # # # # # # # # # # # #
7 odpowiedzi
+ 6
What have you got so far? And do you want a size determined by input?
+ 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.
+ 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+"#")
+ 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.
+ 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 #
+ 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 ^_^
0
Thanks