Posting Source code to Blog–Trial 1
Purpose
The purpose of this python script is to post code to my blog
import time def anagram_finder(): dict, file = {}, open(r’C:\Cauldron\garage\DeliberatePractice\Python\DiveintoPython\sanitized.txt', ‘r’) for line in file: strip_line = line.strip().lower() sort_line = str(sorted(strip_line)) dict.setdefault(sort_line, []).append(strip_line) file.close() counter = 0 for k, v in dict.items() : if len(dict[k]) > 1 : counter+=1
>» start = time.clock()
anagram_finder() end = time.clock() print ‘The time taken for finding anagrams is ‘,end-start, ' seconds’ The time taken for finding anagrams is 0.306371956762 seconds
Working The intention is to create a Pweave file , convert to a rst file . Subsequently use this rst file to blog.