l = [(255, 0, 0), (0, 255, 0), (0, 0, 255), (0, 255, 255), (255, 255, 0)]
d = {(0, 0, 255): ((0, 0, 5), (0, 0, 5), (0, 0, 23), (0, 0, 23)), (255, 0, 0): ((0, 0, 10), (0, 0, 10), (0, 0, 21), (0, 0, 21)), (0, 255, 0): ((0, 0, 15), (0, 0, 15), (0, 0, 21), (0, 0, 21)), (255, 255, 0): ((0, 0, 20), (0, 0, 20), (0, 0, 21), (0, 0, 21)), (0, 255, 255): ((0, 0, 24), (0, 0, 24), (0, 0, 21), (0, 0, 21))}
d2 = sorted(d.items(), key=lambda x:l.index(x[0]))
print (d2)
user_data = {}
try:
user_data[message.from_user.id]
except KeyError:
user_data[message.from_user.id] = initial_data_for_new_user
...
user_data[message.from_user.id] = another_data
>>> cmath.exp(1/3*cmath.log(-1))
(0.5000000000000001+0.8660254037844386j)
>>> -(1**(1/3))
-1.0
total_damage = 0
for damage in users_damage.value():
total_damage += damage
for user, damage in users_damage.items():
user_rating = int(2000*damage/total_damage)
user_reward = int(10**9*damage/total_damage)
print ("User {user} received {user_rating} rating points and {user_reward} bucks")
msg = bot.send_message(message.chat.id, "loading...")
...
bot.edit_message_text("result", chat_id=message.chat.id, message_id=msg.message_id)
bot.delete_message(message.chat.id, msg.message_id)