now that we have some test caseslet' think about how to implement our encoding algorithm writing code to use table like we used in the earlier manual algorithm is possiblebut seems complicatedconsidering that each row is just an alphabet rotated by an offset number of characters it turns out ( asked wikipediathat we can use modulo arithmetic to combine the characters instead of doing table lookup given plaintext and keyword charactersif we convert the two letters to their numerical values (with being and being )add them togetherand take the remainder mod we get the ciphertext characterthis is straightforward calculationbut since it happens on character-by-character basiswe should probably put it in its own function and before we do thatwe should write test for the new functionfrom vigenere_cipher import combine_character def test_combine_character()assert combine_character(" "" "="xassert combine_character(" "" "="enow we can write the code to make this function work in all honestyi had to run the test several times before got this function completely correctfirst returned an integerand then forgot to shift the character back up to the normal ascii scale from the zero-based scale having the test available made it easy to test and debug these errors this is another bonus of test-driven development def combine_character(plainkeyword)plain plain upper(keyword keyword upper(plain_num ord(plainord(' 'keyword_num ord(keywordord(' 'return chr(ord(' '(plain_num keyword_num now that combine_characters is testedi thought we' be ready to implement our encode function howeverthe first thing we want inside that function is repeating version of the keyword string that is as long as the plaintext let' implement function for that first oopsi mean let' implement the test firstdef test_extend_keyword()cipher vigenerecipher("train"extended cipher extend_keyword( assert extended ="traintraintraint