Snuggle / hypixel.py

🎮 This is a simple, unofficial library for getting values from the public Hypixel-API in Python.
https://pypi.org/project/hypixel
MIT License
32 stars 6 forks source link

Please help me #15

Closed urFate closed 4 years ago

urFate commented 5 years ago

How to make it so that if a player has no karma, it would be written something like this: Player Karma: 0 or Player Karma: 110 And did not separate the separate message that there is no karma?

Snuggle commented 5 years ago
def get_karma(player_object):
    try:
        karma = player_object.JSON['karma']
    except KeyError:
        karma = 0

print(f"Player has exactly: {get_karma(player)} karma!")

😛

urFate commented 5 years ago

In any case, if a player has or does not have a karma, the result is always 'none'. :-1:

Snuggle commented 4 years ago

How did you get along with the solution above? If you're still having issues, feel free to reopen an issue!