Add an if statment to everything at once?
Go to solution
Solved by Sauron,
27 minutes ago, Need_Not said:So i was wonding if it's possible to put a 0 on all stats that dont exist with like 2 lines of code?
No.
By the way, your code is completely unreadable - the variable names are meaningless and you didn't really need intermediary variable names for most of them to begin with.
To elaborate on what @minibois suggested, think of something like this:
def getInfo(json, param): try: return int(json['stats']['Bedwars'][param]) except: return 0 ... print("Kills: %d" % (getInfo(Player.JSON, "eight_one_kills_bedwars"))) print("K/D: %.2f" % (getInfo(Player.JSON, "eight_one_kills_bedwars")/getInfo(Player.JSON, "eight_one_deaths_bedwars")))
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now