Python has the enumerate function for these situations.
for i, item in enumerate(items):
#your print statement here
'i' will give you the index of the list/iterable, and item will give you
the item.
On Sat, 14 Nov 2020 at 11:57, paidjoo indo <[email protected]> wrote:
> Hello I'm newbie in python, I'm learning looping in python, how to print
> like in bellow;
> Input:5
> 12345
> 2. 4
> 3 3
> 4 2
> 54321
> Thanks guys
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAO%3D2VJmeOF5SyMZUFox_hHivTr%3DE%3Dnekj_n7FLOYjGOkPHQrbA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAO%3D2VJmeOF5SyMZUFox_hHivTr%3DE%3Dnekj_n7FLOYjGOkPHQrbA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CACaDatTeC6sFyFjiyKhkBjkpYpc7uk8hWsFAfagk8eh4k%3DrQ_w%40mail.gmail.com.