Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+6 votes

I tried to use a loop to get the asterik points for filled and unfilled but when I return it, it only returns the last part or the first part. How do I make it to return the whole square

asked in CSC201 Spring 2021 by (1 point)

2 Answers

+3 votes
 
Best answer

For unfilled: I used multiple print statements. One for the first line of the square, one for the last line. Then I used for loop to draw the body lines.
For filled: I just simply used for loop to draw the entire square

answered by (1 point)
selected by
0

Thank you so much!

+1 vote

Note: You shouldn't be RETURNing anything for RP 16 Q3

Read the problem description carefully. It says that the program should print the output to the console/shell, and says nothing about returning a value.

So, you should really ask -- how do I make it PRINT the whole square as output? And Thu Ho provides some hints there that could be useful. Also, remember about string repetition (multiplication), which can help you avoid writing as many FOR loops. e.g. something like this:

print(' ' * 10)

or

print('*' * 20)
answered by (1.2k points)
...