On 08/02/15 23:01, 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')
Have you tried running it?
Do you see what it is doing?
Try evaluating range(6,0,-1) at the interpreter (you may want to convert
it to a list) to see what it does.
>>> print( list(range(6,0,-1)) )
Try substituting values for (6-r) and see what string
results you get for each value.
eg
>>> print(6 * '' + 0 * 'o')
>>> print(0 * '' + 6 * 'o')
>>> print(3 * '' + 3 * 'o')
>>> print(3 * '' + 4 * 'o')
>>> etc
In other words, experiment in the >>> interpreter. That's
what it's there for. And its quicker than sending an email
and waiting for a reply (which may not cover the bit you
want to understand anyway).
Then if there's still something you don't understand come
back and ask us about that specific aspect.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor