The buildCipher function could create more complicated alphabets. As long as both the receiver and the sender generate the alphabet in the same way, the message needs to only include the keyword for encoding and decoding to work. Try building these variations:
1. Put the keyword at the end of the alphabet, rather than the front:
Note: This is accomplished simply by changing the final line.
2. Reverse the alphabet before concatenating it to the keyword:
Note: This is accomplished by adding a reversal of the “rest” variable prior to concatenating.
3. Separate the vowels and the consonants in the rest of the alphabet so that the cipher alphabet is keyword, then the rest of the vowels, then the rest of the consonants:
Note: We can simply duplicate the work from 3.9 to achieve the desired effect.
1. ```
def buildCipher(key):
alpha="abcdefghijklmnopqrstuvwxyz" rest = ""
for letter in alpha:
if not( letter in key ):
rest = rest + letter
print rest+key
```
2. ```
def buildCipher(key):
alpha="abcdefghijklmnopqrstuvwxyz"
rest = ""
for letter in alpha:
if not( letter in key ):
rest = rest + letter
restReverse = ""
for letter in rest:
restReverse = letter+restReverse
print key + restReverse
```
3. ```
def buildCipher(key):
alpha="abcdefghijklmnopqrstuvwxyz"
rest = ""
for letter in alpha:
if not( letter in key ):
rest = rest + letter
vowels= ""
consonants = ""
for letter in rest:
if letter.lower() in "aeiou":
vowels = vowels + letter
if letter.lower() in "qwrtypsdfghjklzxcvbnm":
consonants = consonants + letter
print key + vowels + consonants
```
You might also like to view...
In a data table, the ________ number format is used to disguise the formula references in the first row as labels
A) Special B) Custom C) Text D) Scientific
What Docker command will allow you to view a list of running containers and display additional information about the running containers?
A. docker ps B. docker exec C. docker rm D. docker attach
Like the CISSP, the SSCP certification is more applicable to the security__________ than to the security __________.
A. technician, manager B. manager, engineer C. manager, technician D. technician, executive
The ____ method removes and returns the first element from the beginning of an array.
A. split() B. unshift() C. shift() D. slice()