[Python] what is "size - 1" argument in this loop?

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

  1. Stack

    Stack Membro Participativo

    word = input("Enter a word: ")
    print("Original String is: ", word)

    size = len(word)

    print("Prnting only even index chars")
    for i in range(0, size - 1, 2):
    print("index[", i, "]", word)


    I need to understand whether "size - 1" was a subtraction or something else.

    I've tried to replace "size - 1" with just "8" and got the same answer. Because the word has 8 characters.

    Continue reading...

Compartilhe esta Página