Python缩进

缩进出现问题,运行不出来。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
View Code

 

直接粘贴,以下,运行报错
code

 

而后,选中所有,alt+ctrl+I自动缩进,以下:blog

仍然须要调整,选中,tab键,总体缩进it

直至最终能够运行。event

目前看来,很不方便,也许还未掌握诀窍class

相关文章
相关标签/搜索