pythonで大文字小文字に関わらず、並べるプログラムを作成しています。入力と出力が以下のようになるようにしたいのですが、
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ',', ',', ',', ',', ',', ',', ',', 'a', 'a', 'b', 'c', 'D', 'e', 'e', 'f', 'i', 'i', 'i', 'i', 'l', 'l', 'l', 'L', 'n', 'n', 'o', 'o', 'o', 'o', 'p', 'r', 'r', 's', 'S', 's', 't', 't', 't', 't', 't', 'T', 't', 'u', 'y']
と出力されてしまいます。以下のコードはどこが間違っていますでしょうか?
よろしくお願いいたします。
入力
int, float, bool, str, Dictionary, Set, Tuple, List
出力
['bool', 'Dictionary', 'float', 'int', 'List', 'Set', 'str', 'Tuple']
コード line1 = input() line2 = sorted(line1, key=str.casefold) print(line2)
回答2件
あなたの回答
tips
プレビュー
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。
2022/05/26 13:27
2022/05/26 13:32 編集
2022/05/26 14:20
2022/05/26 14:25
2022/05/26 14:31