1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] putting a variable into variable name [duplicate]

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

  1. Stack

    Stack Membro Participativo

    I'm basically making a short game, similar to Yahtzee. In it I have a list of categories, and I want to copy that list so each player has their own list that I can remove their used categories from.

    I'm aware that I could just append that list (no of players) times and use indexes but I'm wondering if it is possible to put a variable into the name of another variable. ignore the polish, it's just the language i know the game in.

    kat=["jedynki","dwojki","trojki","czworki","piatki","szostki","pary","dwie pary","trojka","kareta","full","general","maly strit","duzy strit"]
    noofplayers=int(input("Podaj liczbe graczy: "))
    for s in range (noofplayers):
    player_s=kat.copy()
    ##I know currently the list will be called player_s now, but is there something i can change the (_s) to to make it 1,2,3 ect

    Continue reading...

Compartilhe esta Página