Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import string
- cryptogram = "gfmncwmsbgblrrpylqjyrcgrzwfylbrfyrq"$#abbreviated version of the cryptogram
- cryptolist=list(cryptogram)
- def alpha_num_dic(): #creates dictionary with alphabet assigned nums 1 thru 26
- alpha= (string.ascii_lowercase)
- alphalist = list(alpha)
- numrange=range (1,27)
- alphadict = dict(zip(alphalist,numrange))
- return alphadict
- def dictionary(y): #cryptolist passed in
- dictlist = []
- b=alpha_num_dic()
- for item in y: #loop cryptolist
- getkey=b[item] #each cryptolist item is the key for a lookup
- dictlist.append(getkey) #assign value to dictlist
- conversion(dictlist,alpha_num_dic)
- def conversion(z,dictionary):
- newnum=[]
- for value in z:
- if value < 25:
- value += 2
- elif value == 25:
- value = 1
- elif value == 26:
- value = 2
- newnum.append(value)
- reverse_lookup(dictionary,newnum)
- #works up til here. I can't figure out how to iterate through a dictionary.
- def reverse_lookup (dictionary,newnum):
- for item in dictionary: #for passed value in dictionary
- if dictionary[item] == newnum: # if dict[value] ==
- print item
- dictionary(cryptolist)
Add Comment
Please, Sign In to add comment