Python 如何在排序列表或给定数据中搜索特定数据?
如果您看到它没有显示列表中的35个位置 它没有打印值,因为您告诉它只打印标题文本,而不是值Python 如何在排序列表或给定数据中搜索特定数据?,python,sortedlist,Python,Sortedlist,如果您看到它没有显示列表中的35个位置 它没有打印值,因为您告诉它只打印标题文本,而不是值 Enter the required key: 35 Your search key is at position: 解决了这个问题: if found: print("Your search key is at position: ", mid_indx) 如果在_xyz的数据_中搜索_键,则查找=数据_的_xyz.索引(搜索_键)不容易,否则无?或者您只是想知道搜索函数的实现是否正确?变
Enter the required key: 35
Your search key is at position:
解决了这个问题:
if found:
print("Your search key is at position: ", mid_indx)
如果在_xyz的数据_中搜索_键,则查找=数据_的_xyz.索引(搜索_键)不容易,否则无?或者您只是想知道搜索函数的实现是否正确?变量和函数名称应遵循带有下划线的
小写形式。你认为如果找到==True:
如何工作?是的!你说得对,它确实像你提到的那样工作了,谢谢你!
if found:
print("Your search key is at position: ", mid_indx)
[13, 24, 32, 35, 78]
Enter the required key: 35
Your search key is at position: 3