Name of list



  • The user introduces the name, let's say "test," that name becomes a variable list, that is, I need to get something like that in the sense.

    input() = []
    

    Thank you.



  • strange wish

    First decision (may not be exactly what you want):

    list_name = input('введите имя списка: ')
    globals()[list_name] = []
    

    xxx.append(12)
    print(xxx)

    The code will work and get it out. [12] If the user vets xxx

    second decision

    list_name = input('введите имя списка: ')

    data = dict()
    data[list_name] = [1, 2, 3]

    list_name2 = input('введите имя списка из которого получить данные: ')
    print(data[list_name])

    if applicable xxxThen there'll be a list to match the "xxx" in the dictionary.

    if applicable xxx Second request, to be issued [1, 2, 3] from dictionary



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2