I am defining a method within a class which creates a dictionary. This dictionary simply gives each letter of the alphabet a value. So the method doesn't manipulate any instances of that class. Do I need to have self
as a parameter of the method in this case?
def build_shift_dict(self, shift):
import string
low = string.ascii_lowercase*2
up = string.ascii_uppercase*2
punc = list(" !@#$%^&*()-_+={}[]|\:;'<>?,./\"")
shift_dict = {}
for i in low[:26]:
shift_dict[i] = low[low.index(i) + shift]
for i in up[:26]:
shift_dict[i] = up[up.index(i) + shift]
for i in punc:
shift_dict[i] = i
return shift_dict