[Python] Different variables in same "for" loop?

Discussão em 'Python' iniciado por Stack, Agosto 29, 2025.

  1. Stack

    Stack Membro Participativo

    I have some data (ID = Name), and I want to put the names of the given people IDs in a QTableWidget, but I'm having problems with a for loop...

    Here's my code:

    for x in people:
    for y in range(len(people)):
    view.setItem(y, 0, QtGui.QTableWidgetItem(name[x][:-1][1:]))


    where y in view.setItem(y, 0, QtGui.QTableWidgetItem(name[x][:-1][1:])) is the row index on table, I want to make a table with the names of the given IDs.

    This is the result with 3 IDs given:

    | Jhon |
    | Jhon |
    | Jhon |


    and this is what I'd like it to display:

    | Sally |
    | kate |
    | Jhon |


    any help?

    Continue reading...

Compartilhe esta Página