jeudi 23 février 2017

Python simplifying if statement logic

I have a case where I have to use if statement learning python:

if ([Team1_matches[0]>Team2_matches[0] and Team1_matches[1]>Team2_matches[1] and Team1_matches[2]>Team2_matches[2] and
 Team1_matches[3]>Team2_matches[3] and Team1_matches[4]>Team2_matches[4]]):
winner="Team 1"
elif ([Team2_matches[0]>Team1_matches[0] and Team2_matches[1]>Team1_matches[1] and Team2_matches[2]>Team1_matches[2] and
  Team2_matches[3]>Team1_matches[3] and Team2_matches[4]>Team1_matches[4] ]):
winner="Team 2"
else:winner="it was a draw or something went wrong"

It's always returning team 1 for some reason due to my poor combination, please advice how I can achieve the real value for winner, without having to if for many lines, if this is programmatically correct I will do it, just need advice

Aucun commentaire:

Enregistrer un commentaire