Usage python in the index function

 

a = "I will never kiss a guy."

b = a.index("kiss")

print(b)

index can be found directly to the position of a character string inside.

Results: 13

abc = ["M", "K", "O", "L"]

o = abc.index("K")

print (o)

index can also use them in the list.

 

1

Guess you like

Origin www.cnblogs.com/zhaojingjing302/p/11424291.html