程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python: Enter the number of words and find the difference between the maximum and minimum number of letters

編輯:Python

# 1. Enter lowercase words and convert to a list​a=input()# Input word: aASSDSSDFssscvbnb=list(a.lower()) # Convert to lowercase and then convert it to a list and assign it to b# print(b)​# 2. Count the number of letters appearingcounts={} # define empty dictionaryfor word in b:# 2 lines of code statisticscounts[word] = counts.get(word,0) + 1print(counts)​# The maximum value minus the minimum value counts.values() to get the valuedistance = max(counts.values()) - min(counts.values())print(distance)​#Judgment of prime numbers: numbers greater than 1, division by 1 and itself cannot be divisiblefor i in range(2,distance):if distance % i ==0:print("No Answer")print(0)breakelse:print("Lucky Word")print(distance)break


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved