Boxes of O's

Dave Angel davea at davea.name
Sun Mar 2 04:04:13 CET 2014


 geniusrko at gmail.com Wrote in message:
> Well, This is what i got 
> 
> n = int(input("enter number of o: "))
> 
> for i in range(n):
>     print("O", end = '')
>     for j in range(n* 2):
>         print("O", end = '')
>     
>     print()
> 

Are you permitted to write and call functions? If so, then write
 functions to solve pieces of the problem, and call those
 functions from your main one.  That's called factoring,  and is
 an important tool.

In this case,  one function could print a row of 'o' of length
 siz, while the second one print a 'hollow' row. Then your main
 calls first, then loops calling hollow, then calls first
 again.

-- 
DaveA




More information about the Python-list mailing list