2021年2月7日星期日

For loops program to print out a rectangle

I have a problem writing a program with for loops. I am not sure how to go about it but I first of all looped through a string containing a number. And now I need to replicate a string '#' with the individual numbers within that number e.g. I want to replicate the string '#' by replicating it with 2 from '274878'. This is my code so far:

bars_string = input('Enter bars string:\n ')  print('+---------+')  for element in bars_string:    pass  

This is my expected output for a given number string:

Enter bars string:  2378945  +---------+  |##       |  |###      |  |#######  |  |######## |  |#########|  |####     |  |#####    |  +---------+  
https://stackoverflow.com/questions/66094890/for-loops-program-to-print-out-a-rectangle February 08, 2021 at 09:34AM

没有评论:

发表评论