Write a function that uses string key to produce and return a list of integer sh
ID: 3639692 • Letter: W
Question
Write a function that uses string key to produce and return a list of integer shifts, keyShift, based on the index of key's characters within shufAlph. To do this, you will need to loop through the characters of key and find the index of the character key[i] within shufAlph. We will set keyShift[i] equal to this number. Your function should be of the form getKeyShift( key, shufAlph) and should return the list keyShift.As a test, consider the key = 'decaf' with the alphabet shufAlph = 'abcdef'.
This is what I have so far, is this on the right track? (not sure what to make keyShift[i] equal to, and not sure how to loop through the characters of the key and find the index within shufAlph. and do I need to apppend?)
def getKeyShift(key, shufAlph):
keyShift = []
for i in range(len(key)):
keyShift[i] =
return keyShift
Thank you for your time and patience with my ignorance!
Explanation / Answer
PS: Please rate my answer def getKeyShift(key,shufAlph): keyShift = [] for x in range (0,len(key)): for y in range (0,len(shufAlph)): if(key[x] == shufAlph[y]): keyShift.append(y) return keyShift
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.