'Python If not equal several conditions

My aim is to retrieve API from Coinmarketcap and find the sum of market cap without stablecoins.

I use Python and basic loop with if-else. The problem is that I have to check this condition of let's say 500 coins against the set of stablecoins such as "USDT", "USDC", "BUSD".

Below is my attempt for just one condition, but I also need to sum up market cap if they're not USDC and BUSD and other stablecoins.

for item in data["data"]:
    crypto_cap = item["quote"]["USD"]["market_cap"]
    crypto_symbol = item["symbol"]
    if crypto_symbol != "USDT":
        cap_sum += crypto_cap
print(market_cap)


Solution 1:[1]

You might use not in check against list in this case as follows, replace

if crypto_symbol != "USDT":

using

if crypto_symbol not in ["USDT", "USDC", "BUSD"]:

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Daweo