初心者向けのPythonのプログラミング問題です。入門編としてチャレンジしてください。Pythonの正答例は以下になります。
問題124
my_list = [1, 2, 3, 4, 5, 6]
even_numbers = [x for x in my_list if x % 2 == 0]
print(even_numbers)
問題125
from collections import Counter
text = “hello world”
counter = Counter(text)
most_common_char = counter.most_common(1)[0][0]
print(f”最も頻繁に出現する文字は ‘most_common_char’ です”)
問題126
my_list = [“apple”, “banana”, “cherry”]
my_list.sort(key=len)
print(my_list)



コメント