+ 1

I solved 80% of the problem and don't have any idea for the 20%

Problem: In Group B of the World Cup, the teams of Iran, Portugal, Spain and Morocco are present. Write a program that, after receiving the results of the games, prints the name of the team, the number of wins and losses, the difference in goals and points, in a single line, respectively. Each team is printed on a line in order of points. (If the score was equal, the number of wins should be considered. If both the number of wins and the score were equal, they should be printed in alphabetical order.) Iran - Spain Iran - Portugal Iran - Morocco Spain - Portugal Spain - Morocco Portugal - Morocco Sample input: 2-2 2-1 1-2 2-2 3-1 2-1 Sample output: Spain wins:1 , loses:0 , draws:2 , goal difference:2 , points:5 Iran wins:1 , loses:1 , draws:1 , goal difference:0 , points:4 Portugal wins:1 , loses:1 , draws:1 , goal difference:0 , points:4 Morocco wins:1 , loses:2 , draws:0 , goal difference:-2 , points:3 My problem is the condition inside the text brackets above https://code.sololearn.com/cLbzn974mVmG/?re

12th Oct 2021, 5:10 PM
Amirreza
Amirreza - avatar
4 Answers
+ 1
Hmm, this could be hard by your way. I would use another struct of data. Like this: A inner list: Li = [Nation, points, wins, draws, lost, pGoals, mGoals] or goaldiff maybe A outer list to put them together La = [ [Li1], [Li2],... [Lin] ] Then it's possible to bring all the inner list into the right order with three steps 1. Sort nations 2. Sort number of wins 3. Sort points Here you can see how to sort inner lists : https://www.delftstack.com/howto/JUMP_LINK__&&__python__&&__JUMP_LINK/sort-list-of-lists-in-python/
12th Oct 2021, 6:11 PM
Coding Cat
Coding Cat - avatar
+ 1
Here is only a first quick try, because I don't know much about Python. Maybe it would also make sence to create a small class for the teams. https://code.sololearn.com/c0k1dXRpaEgx/?ref=app
15th Oct 2021, 9:31 AM
Coding Cat
Coding Cat - avatar
0
Coding Cat I found out how to do such as this things with lists: by sorting the list with lambda function... I also used map function for it
15th Oct 2021, 10:03 AM
Amirreza
Amirreza - avatar
0
Amirreza Hashemi ah, ok. That sounds good 👍
15th Oct 2021, 10:40 AM
Coding Cat
Coding Cat - avatar