#从['P','Y','T','H','O','N','I','S','V','E','R','Y','G','O' ,'O','D']
# 删除列表中出现次数最多的字母。
在这道题开始前,大家一定要看清楚确认那个字母是出现最多的,确认后,我们首先就要考虑到如何找到这个字母?带着这个思路我们这道题的答案也就出来了。
解决方案如下:
list_1 = ['P','Y','T','H','O','N','I','S','V','E','R','Y','G','O','O','D']
most = list_1[0]
for i in range (1,len(list_1 )):
if list_1.count(list_1[i]) > list_1.count(most ) :
most = list_1 [i]
for j in range (list_1 .count(most)):
list_1.remove(most)
print(list_1 )
注意if判断的条件,然后就是删除的条件!