[Tutor] Explanation of this print statement

Dave Angel davea at davea.name
Mon Feb 9 02:00:19 CET 2015


On 02/08/2015 06:01 PM, Shawn Byers wrote:
> Hello I was wondering if someone could explain this print statement
>
> for r in range(6,0,-1):
>           print((6-r)*''+r*'o')


You probably intended to have a blank between the first two single-quotes.

  for r in range(6,0,-1):
            print((6-r)*' '+r*'o')


Perhaps it'd be more interesting to put some other character in the quotes:

  for r in range(6,0,-1):
            print( (6-r)*'X' + r*'o' )

-- 
DaveA


More information about the Tutor mailing list