[Python] "Expected type 'Sized', got 'int' instead" when trying to check if user input is...

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

  1. Stack

    Stack Membro Participativo

    I was trying to reverse all the numbers in a string. But first I had to check if what the user entered was a number or not. But even when what the user typed in was an integer, PyCharm skipped that if statement.

    print('type a random number consisting of 10 digits')
    l1 = 0


    def loop1():
    global l1
    l1 = int(input())
    if l1 == int():
    if len(l1) != 10:
    print("The number you have entered does not consist of 10 digits. "
    "Please enter a number consisting of 10 digits.")
    loop1()
    else:
    print("You have not entered a proper number. Please enter a proper number")
    loop1()


    loop1()
    l1 = list(l1)
    print(l1[0: 10: 2])


    What am I doing wrong?

    Continue reading...

Compartilhe esta Página