我有,我有if語句學習Python中使用的情況下:Python的簡化if語句邏輯
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"
它總是返回出於某種原因隊1由於我可憐的組合,請諮詢我如何能實現對於贏家的真正價值,而不必如果多條線路,如果這是正確的程序,我會做到這一點,就需要諮詢
如果沒有括號
if Team1_matches[0]>Team2_matches[0] and Team1_matches[1]>Team2_matches[1] and Team1_matches[2]>Team2_matches[2] and
^
信達xError:無效的語法
我得到的輸入是這樣的:
Team1_matches[0] = input("Enter the score that team 1 got on match 1? ")
什麼輸入?爲什麼在你的條件下有'[]'? – depperm
如果條件不符,請移除大括號。 'if([...]):' - >'if ...:'。實際上,您正在檢查布爾值列表的真值,它總是「真」,因爲它不是空的。 –
你也應該看看[如何並行迭代兩個列表](http://stackoverflow.com/questions/1663807/how-can-i-iterate-through-two-lists-in-parallel-in-python )。 –