I'm currently learning the basics in Python, and I need to create a name database of ten people, including other details (phone number, address, birthday, and three interests).
The dream is that upon entering a persons name at the prompt, all of their details will appear. Or upon entering name['phone'], the persons name and phone number will come up. Same for address, birthday, and interests. I've been told that I have to able to get the name and relevant field (phone, hobbies, etc) from the command line, using the argv list, but I'm not sure how to do this. Any help would be much appreciated!
Here is an example of what I've written up for the dictionary:
friends = {'Matt ' : {'phone' : '13579',
'birthday' : '2 Dec',
'address' : 'Sydney',
'interests' : ['a', 'b', 'c' ]},
'Tim ' : {'phone' : '24680',
'birthday' : '19 Feb',
'address' : 'Honolulu',
'interests' : ['x', 'y', 'z' ]},
'Kate ' : {'phone' :'12345',
'birthday' : '30 Jun',
'address' : 'Beijing',
'interests' : ['q', 'w', 'e' ]}
}
name = raw_input ('Please enter search criteria: ')
if name in friends:
print 'yes'
else:
print 'no data'
Thank you kindly!
name.lower()will convert Matt to matt and it will not match...'Matt '...friends[name]['phone'].