fork download
  1. import random
  2.  
  3. me = {'str': 2, 'dex': 3, 'con': 5}
  4. enemy = {'str': 100, 'dex': 4, 'con': 200}
  5.  
  6. def choose(): # случайный атрибут, не превышающий половину вражеского
  7. matching = list(x for x in me if me[x] <= enemy[x] // 2)
  8. if not matching: return None
  9. return random.choice(matching)
  10.  
  11. print(choose(), choose(), choose(), choose(), choose(), choose(), choose(), choose())
Success #stdin #stdout 0.02s 37616KB
stdin
Standard input is empty
stdout
con str con con str con con str