How can I get values from dictionary for particular key using python
<p>In this code, I wanted to identify a member with his ID. If the ID exist in the dictionary, I would like to print the fullname of this member</p>

<pre><code>iin = input('Enter your ID :')
 dict = {'id' : ['aa', 'bb', 'cc'],
        'Firstname' : ['Mark', 'Jamal', 'Van'],
        'Lastname' : ['Roch', 'borh', 'nilsa']}
 for d in dict:
    if inn in d:
       print('Hello,', dict[inn])
    else :
       print('Sorry, you are not a member')
</code></pre>

<p>The desired result</p>

<pre><code>Enter your ID : aa
Hello, Mark Roch
</code></pre>

<p>Thank you for the help</p>

<p>Using .items() will allow for a loop on a dictionary.</p>

<pre><code>iin = input('Enter your ID :')
dict = {'id' : ['aa', 'bb', 'cc'],
        'Firstname' : ['Mark', 'Jamal', 'Van'],
        'Lastname' : ['Roch', 'borh', 'nilsa']}
for k, v in dict.items():
    if k == 'id':
        loc = v.index(iin)
        print("Hello, {} {}".format(dict['Firstname'][loc], dict['Lastname'][loc]))
else:
    print('Sorry, you are not a member')
</code></pre>

python for-loop dictionary input output