Click here to Skip to main content
15,920,633 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HomeTeamName=(input("Home Team Name:  "))
HomeRuns=int(input("Home Runs: "))

AwayTeamName=(input("Away Team Name:  "))
AwayRuns=int(input("Away Runs: "))
WinningTeamName=0
RunDifference=0

RunDifference=HomeRuns-AwayRuns


if HomeRuns>AwayRuns:
   HomeTeamName==WinningTeamName
   print("Winning Team was{0}, who scored {1}more runs".format(HomeTeamName, RunDifference))

else:
     AwayTeamName==WinningTeamName
     print("Winning Team was  {0} , who scored  {1}  more runs".format(AwayTeamName, RunDifference))


What I have tried:

I tries using the built in abs(x) function but it doesnt work
Posted
Updated 4-Apr-16 21:17pm
Comments
Richard MacCutchan 5-Apr-16 3:54am    
Check first which value is greater before you calculate the difference and always subtract he smaller from the larger.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900