思路:这道题我们只需要对输入字符串统一格式,统计"GPLT"每个字符的数量,然后按照顺序输出即可
import sys
list_1 = [x for x in sys.stdin.readline().upper()]
G_out,P_out = list_1.count('G'),list_1.count('P')
L_out,T_out = list_1.count('L'),list_1.count('T')
while G_out > 0 or P_out > 0 or L_out > 0 or T_out > 0:
if G_out != 0:
print('G',end="")
G_out -= 1
if P_out != 0:
print('P',end="")
P_out -= 1
if L_out != 0:
print('L',end="")
L_out -= 1
if T_out != 0:
print('T',end="")
T_out -= 1