縮進出現問題,運行不出來。ide
正確代碼以下:spa
1 def binary_search(list, item): 2 low = 0 3 high = len(list)-1 4 5 while low <= high: 6 mid = (low + high) 7 guess = list[mid] 8 if guess == item: 9 return mid 10 if guess > item: 11 high = mid-1 12 else: 13 low = mid + 1 14 return None 15 16 my_list = [1, 3, 5, 7, 9] 17 print (binary_search(my_list, 3)) # => 1
直接粘貼,以下,運行報錯
code
而後,選中所有,alt+ctrl+I自動縮進,以下:blog
仍然須要調整,選中,tab鍵,總體縮進it
直至最終能夠運行。event
目前看來,很不方便,也許還未掌握訣竅class