Hi,

Below is the snippet from my script which is working fine

if system is 'Conferences':
        assignedtomatrix[system]['Third'] = 'name'

I have to now introduce one more loop checking, but could not find a way to do this.

I have tried:

if system is 'Conferences':
        person = ['person1', 'person2', 'person3']
        community = communities [:]
        if community is 'Arts':
          person = 'person1'
        if community is 'Book':
          person = 'person2'
        if community is 'Learning':
          person = 'person3'
        assignedtomatrix[system]['Third'] = person

But I think this is not entering into If loop for community.

Please help.

Shrik

Do not use "is", unless you really mean object identity, which you obviously don't.
Use:
system == 'Conferences'
community == 'Arts'

I do not know what in communities is. If it is a list, then a copy of a list will never be equal or identical with a string literal.
If it is a string then identity is an implementation detail, equality must work.

If communities is a list, you may want to use something like for community in communities: as a loop. If itself or community = communities [:] does not form a loop.

And dont mix indentation now you have 8 spaces and 2 spaces.
Always use 4 spaces.
Look at PEP 8

And you can use a dictionary as a container for all of this, so if you want to change anything, you just add, change, or delete from the dictionary. Your code assumes that just one hit will be found. If there is more than one, "person" will be whatever was found last.

test_dict = {}
test_dict['Arts'] = 'person1'
test_dict['Book'] = 'person2'
test_dict['Learning'] = 'person3'
if system == 'Conferences':
    person = ""
    for key in test_dict:
        if key in communities:
            person = test_dict[key]
    if len(person):     ## something was found
        assignedtomatrix[system]['Third'] = person

Hi,
Thanks all. Not yet succeeded.
I have tried woooee's code, but I think it is mapping for the last person only. Sorry for any confusion but I want it should map to the particular person only.
Previously I have following:

systems =  ['Accounts','Journals','Conferences','Proposals','Accommodation','Complaints', 'Sponsorship']
levels =      ['First','Second','Third','Fourth']
assignedtomatrix = {}
for system in systems:
    assignedtomatrix[system] = {}
for level in levels:
    for system in systems:
        assignedtomatrix[system][level] = ''
for system in systems:
	# Code Goes here For Level wise and system wise

Now I have to introduce Third list communities so assignedtomatrix will also check for system,level,communities & then assign to the person.

I have defined communities as:
communities =

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.