اكتب برنامج باستخدام لغة بايثون python لحساب عدد كل كلمة داخل نص
- برمجة
- برمجة بايثون
- 2021-04-14
- daafoor
الأجوبة
def word_count(str):
counts = dict()
words = str.split()
for word in words:
if word in counts:
counts[word] += 1
else:
counts[word] = 1
return counts
print( word_count('the quick brown fox jumps over the lazy dog.'))
output
{'the': 2, 'jumps': 1, 'brown': 1, 'lazy': 1, 'fox': 1, 'over': 1, 'quick': 1, 'dog.': 1}
القوائم الدراسية التي ينتمي لها السؤال