current position:Home>A list that contains only strings. What other search methods can be used except sequential search

A list that contains only strings. What other search methods can be used except sequential search

2022-01-27 02:43:41 CSDN Q & A

Because I know that the dichotomy must be an ordered sequence , Ask for help




Refer to the answer 1:

What are you doing ? Find the specified character ?
Order first , Then use two points to find .




Refer to the answer 2:



Refer to the answer 3:
list=['dfsd','cea','werere','ddd','sdfds']index=list.index('cea')print(index)###1



Refer to the answer 4:



Refer to the answer 5:

Strings can also be ordered sequences , Sort it first
python You can directly judge whether there is , With keywords in
You can also directly obtain index, It seems that you don't need any search methods




Refer to the answer 6:



Refer to the answer 7:

Can order , In reverse order , You can sort the last two




Refer to the answer 8:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201270243389440.html

guess what you like

Random recommended