Python Forum
how to avoid a lot of 'if' statments ?
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to avoid a lot of 'if' statments ?
#11
(Aug-27-2018, 12:55 PM)Gribouillis Wrote:
(Aug-27-2018, 12:06 PM)witch Wrote: why does it execute choice 1,2,3 at a same time?
Use a list and write simply
politicians = [ryashko, poroh, yacenyuk, tymoshenko]

pol1 = (int(input('Хто буде бити ? (Виберіть цифру)\n')))
pol2 = (int(input('Кого будуть бити ? (Виберіть цифру\n')))

politicans[pol1 - 1].attack(politicians[pol2 - 1])
This also works, thanks for reply, I appericate it ! any idea on how to loop it, so the game doesnt end after one choice ?
Reply


Messages In This Thread
how to avoid a lot of 'if' statments ? - by witch - Aug-27-2018, 11:36 AM
RE: how to avoid a lot of 'if' statments ? - by witch - Aug-27-2018, 01:02 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020