{}
62
%OFF

Stop copy pasting code you don't actually understand

Build the coding confidence you need to become a developer companies will fight for

Stop copy pasting code you don't actually understand

Become a PRO
Become a PRO
62
%OFF

Stop copy pasting code you don't actually understand

Build the coding confidence you need to become a developer companies will fight for

Stop copy pasting code you don't actually understand

Become a PRO
Become a PRO
run-icon
main.py
# Online Python compiler (interpreter) to run Python online. # Write Python 3 code in this online editor and run it. import re from collections import Counter def analyze_text(file_path): with open(file_path, 'r', encoding='utf-8') as f: text = f.read().lower() words = re.findall(r'\b\w+\b', text) total_words = len(words) most_common = Counter(words).most_common(10) print(f'Total words: {total_words}') print('Top 10 frequent words:') for word, count in most_common: print(f'{word}: {count}') # Example usage # analyze_text('sample.txt')
Output