I am wondering how I could print a certain value of a variable on a text string. Here is my code.
import requests
import time
import json
urls = ["https://api.opensea.io/api/v1/collection/doodles-official/stats",
"https://api.opensea.io/api/v1/collection/boredapeyachtclub/stats",
"https://api.opensea.io/api/v1/collection/mutant-ape-yacht-club/stats",
"https://api.opensea.io/api/v1/collection/bored-ape-kennel-club/stats"]
for url in urls:
response = requests.get(url)
json_data= json.loads(response.text)
data= (json_data["stats"]["floor_price"])
print("this is the floor price of {} of doodles!".format(data))
print("this is the floor price of {} of Bored Apes!".format(data))
As you can see in the code I am using the opensea API to extract the value of floor price from a json file of the different NFT collections listed on the urls.
The variable if you print the variable data you will get the different prices as follow:
The question is how can I take a specific value of that output, lets say 7.44 for example, and print in the following text
print("this is the floor price of {} of doodles!".format(data))
and then use the second value, 85, and print another text such as:
print("this is the floor price of {} of Bored Apes!".format(data))
How can I generate this output? Thanks everyone!
I tried using data[0] or data[1], but that doesn't work.