[Python] Extracting the slice arguments in variables

Discussão em 'Python' iniciado por Stack, Dezembro 31, 2024.

  1. Stack

    Stack Membro Participativo

    Lets assume we have the Python line:

    print(languages[1::2])


    Is there any generic way to extract the values of start, stop and step in other variables?

    I want to see a start variable with value 1, a stop variable with None and a step variable with value 2 or a tuple of these three elements

    I am new in Python and I wondering if I can create a program which will simulate the slice functionality for strings, lists and tuples just as an coding exercise.

    So I need to extract the values of a previously executed print command and use them.

    Continue reading...

Compartilhe esta Página