Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4101146
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:39:32+00:00 2026-05-20T20:39:32+00:00

For the first time this is not python => php but php => python.

  • 0

For the first time this is not python => php but php => python.
I’ve got small problem with arrays in python.
(I’ve already been to docs.python.org)

Here’s my problem:
I get in python couples of strings like this:

(People 1):
  <criteria a> <data of the criteria>
  <criteria b> <data of the criteria>
  <criteria c> <data of the criteria>
  <criteria d> <data of the criteria>
(People 2):
  <criteria a> <data of the criteria>
  <criteria b> <data of the criteria>
  <criteria d> <data of the criteria>
...

(note for people 2 criteria c doesn’t exist)
So i’d like do that (in php it’s very easy):

array_push( tab[ "criteria a" ],
    array("People1", "data of the criteria")
);

Then I’d like to show all a list of the criterias that exists, and use the array to create a nice “insert SQL query” for my database.

Any idea how to do this?
Where should I look?
I miss string indexed arrays….

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T20:39:33+00:00Added an answer on May 20, 2026 at 8:39 pm

    In Python you have “dictionaries” instead of “string indexed arrays”.
    Their syntax is different than for arrays.

    You can do

    data = {}
    data["people 1"] = {}
    data["people 1"]["criteria a"] = "bla"
    data["people 1"]["criteria b"] = "ble"
    data["people 2"] = {}
    

    …

    You can retrieve all contents of a dictionaries values using the values method:

    >>> print data["people 1"].values()
    ["ble", "bla"]
    

    (note that order is arbitrary when you do this)
    Anyway, you’d better check the documentation on Python basic data structures to do this:
    http://docs.python.org/tutorial/datastructures.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, so this is not the first time I've had this problem, but it
It's not the first time I'm having this problem, and it's really bugging me.
This is my first time working with file i/o in java, and it's not
I've been learning sqlite3 programming in C++ for the first time and this error
This is the first time I got this error. This code basically gets the
I'm been a PHP developer for quite some time now but until today I've
This is my first time using the LinkedIn API. I am using Python. I
I am now on the road to learn Python (not the first time I
First time python user here, be gentle.... ;-) Python 2.6 on OSX Got a
This is my first time using this site and I am quite new to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.