我有一个这样的列表:
self.thislist = ['Name', 13, 'Name1', 160, 'Name2', 394]
Run Code Online (Sandbox Code Playgroud)
基本上,列表后面有一个名称和一个数字,我试图找出列表中的最高数字,即394.但出于某种原因,它选择了一个名字this.
if max(self.thislist) > 150:
this = max(self.thislist) # so this should be 394
position = self.thislist.index(this) # The index of it
temponary = position - 1 # This is so we can find the name that is associated with it
name = self.thislist[temponary] #and this retrieves the name
Run Code Online (Sandbox Code Playgroud)
例如,'Name'当它应该是394时,它会检索.因此,重点是检索与该名称相关联的名称和数字.有任何想法吗?