Enter your name, age & score: a 17 99
Enter your name, age & score: a 19 98
Enter your name, age & score: a 19 100
Enter your name, age & score: a 19 99
Enter your name, age & score: b 19 99
Enter your name, age & score: b 19 98
Enter your name, age & score: b 19 100
Enter your name, age & score: -1
输出:我该怎么办元组排序
(('a', '17', '99'), ('a', '19', '100'), ('a', '19', '98'), ('a', '19', '99'), ('b', '19', '100'), ('b', '19', '98'), ('b', '19', '99'))
输出应该是这样的:
(( 'A', '17', '99'),(” ('a','19','98'),('a','19','99'),('a','19','100'),('b','19',' ('b','19','99'),('b','19','100'))
我该怎么做?这是我的代码..
def check(txt):
global c
if txt.count(" ") == 2:
tup=(tuple(txt.split(" ")))
list1.append(tup)
list1.sort()
else:
if txt != "-1":
c= 1
return c
main() # prints the converted list to tuple..
我你如何试图对它们进行排序不清楚。 – miradulo
获取该输出的规则是什么?你的输出对我没有任何意义 – SirParselot
为什么99,98,100? –