Re: Lists inside dictionary and how to look for particular value

2014-01-27 Thread Peter Otten
mick verdu wrote: > ThanK you. It solved my problem. > Can someone tell me how can i print particular value inside list of key. > > I know how to print J['PC2'][1] means will print IP. but I want the user > to input some element and I will print element just before that element. > > e.g. if user

Re: Lists inside dictionary and how to look for particular value

2014-01-26 Thread mick verdu
ThanK you. It solved my problem. Can someone tell me how can i print particular value inside list of key. I know how to print J['PC2'][1] means will print IP. but I want the user to input some element and I will print element just before that element. e.g. if user inputs 192.168.0.2, program wil

Re: Lists inside dictionary and how to look for particular value

2014-01-26 Thread Gregory Ewing
mick verdu wrote: What I want is if host already exists it would overwrite otherwise add to database. And if host doesn't exist it will first add this host to database and then compare its IP with IPs of rest of hosts. If ip matches with any of the other hosts, it will delete the host that it jus

Re: Lists inside dictionary and how to look for particular value

2014-01-26 Thread mm0fmf
On 26/01/2014 20:28, mick verdu wrote: I have programming course and trying to learn things. This is of no human use. I am just following exercises. Just have to do steps as asked. A slightly OT observation... Mick, consider using more meaningful names than t,z etc. You know what they stand

Re: Lists inside dictionary and how to look for particular value

2014-01-26 Thread Denis McMahon
On Sun, 26 Jan 2014 10:47:11 -0800, mick verdu wrote: > z={ 'PC2': ['02:02:02:02:02:02', '192.168.0.2', '200'], > 'PC3': ['03:03:03:03:03:03', '192.168.0.3', '200'], 'PC1': > ['01:01:01:01:01:01', '192.168.0.1', '200'] } > > My solution: > > z=raw_input("Enter Host, Mac, ip and time") >

Re: Lists inside dictionary and how to look for particular value

2014-01-26 Thread mick verdu
I have programming course and trying to learn things. This is of no human use. I am just following exercises. Just have to do steps as asked. -- https://mail.python.org/mailman/listinfo/python-list

Re: Lists inside dictionary and how to look for particular value

2014-01-26 Thread mick verdu
@Peter Otten: I have lists for keys. What I want is if host already exists it would overwrite otherwise add to database. And if host doesn't exist it will first add this host to database and then compare its IP with IPs of rest of hosts. If ip matches with any of the other hosts, it will delete

Re: Lists inside dictionary and how to look for particular value

2014-01-26 Thread Tim Chase
On 2014-01-26 10:47, mick verdu wrote: > z={ 'PC2': ['02:02:02:02:02:02', '192.168.0.2', '200'], > 'PC3': ['03:03:03:03:03:03', '192.168.0.3', '200'], > 'PC1': ['01:01:01:01:01:01', '192.168.0.1', '200'] } > > My solution: > > z=raw_input("Enter Host, Mac, ip and time") > t=z.split() > t[

Re: Lists inside dictionary and how to look for particular value

2014-01-26 Thread Peter Otten
mick verdu wrote: > z={ 'PC2': ['02:02:02:02:02:02', '192.168.0.2', '200'], > 'PC3': ['03:03:03:03:03:03', '192.168.0.3', '200'], > 'PC1': ['01:01:01:01:01:01', '192.168.0.1', '200'] } > > My solution: > > z=raw_input("Enter Host, Mac, ip and time") > t=z.split() > t[0]=z[1:] > for key i

Lists inside dictionary and how to look for particular value

2014-01-26 Thread mick verdu
z={ 'PC2': ['02:02:02:02:02:02', '192.168.0.2', '200'], 'PC3': ['03:03:03:03:03:03', '192.168.0.3', '200'], 'PC1': ['01:01:01:01:01:01', '192.168.0.1', '200'] } My solution: z=raw_input("Enter Host, Mac, ip and time") t=z.split() t[0]=z[1:] for key in dic: if t[2] in dic[key]: