正在加载图片...
上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY A Simple Searching Problem We can test to see if a value appears in a sequence using in. if x in nums: do something If we want to know the position of x in a list,the index method of list can be used. >>>nums=[3,1,4,2,5] >>nums.index (4) 2 77 A Simple Searching Problem • We can test to see if a value appears in a sequence using in. if x in nums: # do something • If we want to know the position of x in a list, the index method of list can be used. >>> nums = [3, 1, 4, 2, 5] >>> nums.index(4) 2
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有