[Python] why does my code think that my string is an int? [closed]

Discussão em 'Python' iniciado por Stack, Setembro 12, 2025.

  1. Stack

    Stack Membro Participativo

    In python, I am trying to run a loop upon the condition that the length of my string is less than 9, however I am getting an error as the program seems to think my string 'pandigital' is actually an int, and therefore has no length attribute. Thanks in advance Image

    def pandigital1_9(x):
    pandigital = ""
    i=1
    while len(pandigital) <9:
    if len(pandigital) >9:
    return
    a = i * x
    str(a)
    pandigital =+ a
    i+=1
    return pandigital


    I tried to redefine 'pandigital' as a string by using 'str(pandigital)' on top of making it equal to "", but the program still thinks that the variable is an int

    Continue reading...

Compartilhe esta Página