Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Only 1st character of value in JSON is printing?

import requests
import json
url = "https://betkarma.com/api/propsComparison?startDate=2023-10-17&endDate=2023-10-23&league=nfl"
response = requests.get(url)
data = response.json()
print(response)
for player_name in data["games"][0]["offers"][0]["player"]:
    if offers[0] == "player":
        value = player["value"] 
break
print(player_name)


The above code appears to be correct; however, something certainly is missing in the code below. I’m expecting the first and last name of each participant, but I’m just getting the first letter of the first person’s first name returned for some reason. Any assistance is highly appreciated. I’m not sure whether I’m not outputting the correct thing, if some code is missing, or what I need to do to get a list of names. I’m I’m a noob in python!

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

try this:

import requests

url = "https://betkarma.com/api/propsComparison?startDate=2023-10-17&endDate=2023-10-23&league=nfl"
response = requests.get(url)
data = response.json()

for p in data.get("games")[0].get("offers"):
    print(p["player"])

output:

Foye Oluokun
Foye Oluokun
Michael (Saints) Thomas
Michael (Saints) Thomas
Pete Werner
Pete Werner
Demario Davis
Demario Davis
Marshon Lattimore
Demario Davis
Marshon Lattimore
Pete Werner
Marshon Lattimore
Alontae Taylor
Alontae Taylor
Alontae Taylor
Carl Granderson
Carl Granderson
Carl Granderson
Jaguars DST
Saints DST
Blake Grupe
Brandon McManus
Blake Grupe
Blake Grupe
Brandon McManus
Brandon McManus
Brandon McManus
Blake Grupe
Devin Lloyd
Devin Lloyd
Devin Lloyd
Foyesade Oluokun
Derek Carr
Trevor Lawrence
Trevor Lawrence
Derek Carr
Derek Carr
Derek Carr
Trevor Lawrence
Derek Carr
Trevor Lawrence
Trevor Lawrence
Derek Carr
Derek Carr
Derek Carr
Trevor Lawrence
Derek Carr
Derek Carr
Taysom Hill
Trevor Lawrence
Trevor Lawrence
Alvin Kamara
Travis Etienne Jr.
Travis Etienne Jr.
Travis Etienne Jr.
Alvin Kamara
Tank Bigsby
Alvin Kamara
Alvin Kamara
Travis Etienne Jr.
Travis Etienne Jr.
Alvin Kamara
Travis Etienne Jr.
Travis Etienne Jr.
Alvin Kamara
Alvin Kamara
Travis Etienne Jr.
Alvin Kamara
Travis Etienne
Travis Etienne
Travis Etienne
Travis Etienne
Travis Etienne
Travis Etienne
Travis Etienne
Travis Etienne
Andre Cisco
Andre Cisco
Rayshawn Jenkins
Marcus Maye
Marcus Maye
Rayshawn Jenkins
Rayshawn Jenkins
Andre Cisco
Marcus Maye
Evan Engram
Foster Moreau
Foster Moreau
Foster Moreau
Evan Engram
Evan Engram
Evan Engram
Taysom Hill
Rashid Shaheed
Michael Thomas
Chris Olave
Calvin Ridley
Christian Kirk
Michael Thomas
Chris Olave
Rashid Shaheed
Rashid Shaheed
Calvin Ridley
Christian Kirk
Calvin Ridley

python code print images

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading