python
1def combsort(a): 2 h = len(a) 3 swapped = False 4 while h > 1 or swapped: 5 if h > 1: 6 h = h*10/13 7 swapped = False 8 for i in range(0,int(len(a)-h-1)): 9 if a[i] > a[i+h]: 10 temp = a[i] 11 a[i] = a[i+h] 12 a[i+h] = temp 13 swapped = True
python
1 10 swapped = False 2 11 for i in range(0,int(len(a)-h-1)): 3---> 12 if a[i] > a[i+h]: 4 13 temp = a[i] 5 14 a[i] = a[i+h] 6TypeError: list indices must be integers or slices, not float 7
とエラーが出ました。float型にならないように、1.3で割ったのちにintで整数にしたつもりなのですが、ご指導お願いします。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/04/13 06:45