我想循環輸入字符串的元素,並從字典中獲取它們。我究竟做錯了什麼?TypeError:'字典'對象不可調用
number_map = { 1: -3, 2: -2, 3: -1, 4: 1, 5: 2, 6: 3 }
input_str = raw_input("Enter something: ")
strikes = [number_map(int(x)) for x in input_str.split()]
strikes = [number_map(int(x)) for x in input_str.split()]
TypeError: 'dict' object is not callable
從你給它的例子看起來像一個數組會更好的完成這個任務。 –