0
我有一個填充了用戶輸入的字符串(客戶名稱)的wxListBox。我必須計算列表中最常出現的名稱和最少出現的名稱。我必須使用循環。計算wxListBox中最常見的字符串
下面是實際的代碼與僞代碼喜憂參半,但我有邏輯的麻煩:
cust_name = ""
for names in range(self.txtListBox.GetCount()):
for compareName in counterList:
if:
names == compareName:
count += 1
else:
add names to counterList
set count to 1
什麼是Python中的循環來做到這一點的最好方法是什麼?
這絕對是最簡單的方法,但我應該使用循環。 – 2014-10-05 22:43:49
你仍然可以使用循環,只需使用c.update(name) – 2014-10-05 22:46:20
真棒,感謝@Padraic – 2014-10-05 22:56:23