Question: I have a dictinary with key values in python. I want to loop through to see if a specific value exsists in the dictinary. if
I have a dictinary with key values in python. I want to loop through to see if a specific value exsists in the dictinary. if the value exsists than i want to add the key to a array and the value to another array. how do i retrive that key? im also having trouble adding getting the key to add
dic {"mark": "twain", "john": "doe", "steven": "shark"}
firstName= [] lastName= []
fName = input ("enter a first name")
#loop through every key value in the array
for item in dic:
if fName in dic:
firstName.append(dic[fName ])
lastName.append(dic.keys())
i want to add the first name to to firstName array and the last name to the lastName array. and to loop through the whole dictinary
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
