初心者向けのPythonのプログラミング問題です。入門編としてチャレンジしてください。Pythonの正答例は以下になります。
問題412
numbers = [1, 2, 3, 4, 2, 3]
duplicates = [x for x in set(numbers) if numbers.count(x) > 1]
print(duplicates) # [2, 3]
#>は半角記号に変換
問題413
numbers = [1, 5, 3, 9, 2]
difference = max(numbers) – min(numbers)
print(difference) # 8
問題414
string = “hello world”
no_spaces = string.replace(” “, “”)
print(no_spaces) # helloworld



コメント