''' It is the second part of actually encoding message/file content I am struggling with. Not allowed to import modules other than standard random module. Have to use string methods, lists, and dictionaries. '''
import random def main(): user = int(input('Enter a number: ')) random.seed(user) message = input('Enter message: ') create_code_list(user) encode(user,message) def create_code_list(user): letter = 'abcdefghijklmnopqrstuvwxyz' code_list = (random.sample(range(0,26),len(letter))) print (code_list) return code_list def encode(code_list,message): letter = 'abcdefghijklmnopqrstuvwxyz' letter_list = list(letter) code_list = create_code_list(letter_list) string_list = list(string) c = {} for i in range(len(letter_list)): c[string_list[i]] = letter[i] main()
https://stackoverflow.com/questions/65768700/please-see-attached-imagehow-to-use-letters-based-on-pseudo-random-numbers-to January 18, 2021 at 12:06PM
没有评论:
发表评论