I have the following code
with open('states.json') as f:
data = json.load(f)
for state in data["jquery"]:
if(argumentos[2] == state['version']):
print(state['name'], state['version'] + "existe")
else:
print("nao tem")
when running the program in python
python programa.py jquery 3.3.1
it should look in json where jquery is written and check if it has the second parameter that is version 3.3.1
But in my code above it runs through all json giving me the following output
jquery 3.3.1 existe
nao tem
he is validating the 2 lines if he finds it should show success message otherwise he should show message that does not exist only that he shows me the 2 messages because in json the first block is true and the second is false in the output end I just want you to show me whether there is what I'm looking for or not.
My json
{
"jquery":[
{
"name": "jquery",
"version": "3.3.1",
"extension": "js",
"caminho": "https://code.jquery.com/jquery-3.3.1.min.js"
},
{
"name": "jquery",
"version": "1.5.6",
"extension": "js",
"caminho": "https://code.jquery.com/jquery-1.5.6.min.js"
}
],
"bootstrap":[
{
"name": "bootstrap",
"version": "1.2.8",
"caminho": "https://bootstrap.com.br"
}
]
}
If anyone can give me a help thank you