Python Basics

Chris Angelico rosuav at gmail.com
Fri Oct 3 14:04:39 EDT 2014


On Sat, Oct 4, 2014 at 3:54 AM,  <diarmuid.higgins at mycit.ie> wrote:
> Hi Chris
> I can't get the code to display the output as it should.
> I can get it to display like this:
> 122333444455555 or I can get it to display like this:
> 1
> 2
> 2
> 3
> 3
> 3
> 4
> 4
> 4
> 4
> 5
> 5
> 5
> 5
> 5
> but not as has been asked in the question.

Good! (It would help if you explained how you had the two different
versions, incidentally.) What you need is like the first version, only
you want to break the lines every time the digit changes. That can be
done pretty easily. All you need to do is print out nothing, followed
by end-of-line; and you need to do this in such a way that it happens
after all of one digit has been displayed, but before the next one is.
Can you do that?

Side point: Google Groups makes a horrible mess of your posts. Please
consider switching to the mailing list, or to a better newsreader. You
can join the mailing list here:

https://mail.python.org/mailman/listinfo/python-list

Thanks!

ChrisA



More information about the Python-list mailing list