如何在没有循环的情况下将list转换为字符串,在Python中将join()转换为

Hum*_*mad 2 python sorting string list type-conversion

我有一个排序列表的任务,如下所示:

Input:  "Sorting1234"
Output: "ginortS1324"
Run Code Online (Sandbox Code Playgroud)

不使用join()方法,用于同时在代码的任何地方.经过大量尝试以所需方式排序后,我成功了,但我无法将其打印为字符串

My Output is: ['g', 'i', 'n', 'o', 'r', 't', 'S', '1', '3', '2', '4']
Run Code Online (Sandbox Code Playgroud)

这是我用sorted()排序的算法:

st=input()
def iseven(x):
if x.isdigit():
    return int(x)+9 if int(x)%2==0 else int(x)
res=sorted(st, key=lambda x: (x.isdigit(), x.isupper(), iseven(x), ord(x) ))
print(res)
Run Code Online (Sandbox Code Playgroud)

请帮帮我

Eug*_*ash 6

但我无法将其打印为字符串

只需*在调用时使用运算符将参数解包出列表print()""用作分隔符:

>>> L = ['g', 'i', 'n', 'o', 'r', 't', 'S', '1', '3', '2', '4']
>>> print(*L, sep="")
ginortS1324
Run Code Online (Sandbox Code Playgroud)