0
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 python script
python programa.py jquery 3.3.1
it should search in json where this written jquery and check if it has the second parameter which is version 3.3.1
only that in my code above it goes through the whole json giving me the following exit
jquery 3.3.1 existe
nao tem
he’s validating the 2 lines, if you find it should show success message otherwise it should show message that there is not only that it shows me the 2 messages because in json the first block is true and the second is false in the final output I just want you to show me if there is what I am looking for or nay.
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 help me I’d appreciate
Tip: Set a variable to False, check and if you find the value set to True, then you display the result based on the variable value, you can even exit the loop if you find the value
– Denis Rudnei de Souza
I tried to do it the way you told me but I’m probably doing it wrong and I can’t get the result I want if you can give me a simple example
– jose