In general, I didn’t understand a bit how to make sure that he chose a random slot in which he hit, sorry for a rather stupid question, new to this, here’s the code:

text += ( "☠ После долгой схватки, " + users[0]["first_name"] + " " + users[0]["last_name"] + " и " + (player1.weapon.name.lower() if player1.weapon else " никчемный меч ") + " дoбивают пeрcонaжа " + users[1]["first_name"] + " " + users[1]["last_name"] + " ударом в " + (player2.helm.name.lower() if player2.helm else (player2.tors.name.lower() if player2.tors else "никчемный нагрудник")) ) 
  • what would he choose one of those that there is if player helm if player tors, if they are, if not then useless sword, etc.) - K-9

1 answer 1

Perhaps random.choice () will suit you:

 import random slots = [ "some helm", "another helm", "yet another helm" ] print(random.choice(slots)) 
  • and you can do this slots = [player1.helm.name.lower () if player1.helm else "No"]? - K-9
  • @ MikhailGnida, I didn’t understand the meaning of this action, slots can be filled with any number of elements available for impact, not only helm 'om - LXA
  • Understood thank you very much, sorry for the time taken. - K-9
  • Please, but for the future, please specify the questions that Twiss asked for, this makes it easier to find a solution. - LXA
  • I will try, thank you again - K-9