Why is this weird behaviour:
a = ['This','is','some','banana']
"_".join(sorted(a)).
Output -
This_is_banana_some
It should give the output -
is_banana_some_this
Am I missing something?
Why is this weird behaviour:
a = ['This','is','some','banana']
"_".join(sorted(a)).
Output -
This_is_banana_some
It should give the output -
is_banana_some_this
Am I missing something?
You need to specify the sorting key - lowercase str
in your case.
"_".join(sorted(a, key=str.lower))
This works. By default python places uppercase first.