[Python] Issue with extra zero when printing pattern using python

Discussão em 'Python' iniciado por Stack, Fevereiro 14, 2025.

  1. Stack

    Stack Membro Participativo

    Pattern I need to generate:


    1
    22
    333
    4444


    I need to use python and abide by the following conditions:

    • Don't use strings
    • Number of lines must be 2
    • Only 1 for loop allowed
    • User inputs only
    • Don't use any extra libraries
    My attempt which kinda works but prints an additional zero:


    >>> for i in range(int(input())):
    ... print(((10**i)//9)*i)
    ...
    5
    0
    1
    22
    333
    4444

    Continue reading...

Compartilhe esta Página