You will face a number of technical challenges in this problem. Here are some comments/hints.
\rat the end of your encoded message. For example:
Please enter the message to encode: hello Please enter an integer key between -30 and 100: 90 [194, 191, 198, 198, 201, 103]Note the user string seems to have 5 characters, while the list of numbers that encodes it has 6 numbers. The last one is that invisible carriage return (13 plus the 90 that is the key, hence 103).
message = input("Please enter the message to encode: ")with:
message = input("Please enter the message to encode: ").strip()That will strip away the carriage return (and also any spaces or tabs before or after the input string).
184, 181, 188, 188, 191, 112, 196, 184, 181, 194, 181then you probably want this input to be stored in a variable in your program as a list of numbers, like this:
[184, 181, 188, 188, 191, 112, 196, 184, 181, 194, 181]There is no simple SINGLE line to accomplish this transformation from string-of-numbers to list-of-numbers. However, there is a simple TWO-step approach.
['184', '181', '188', '188', '191', '112', '196', '184', '181', '194', '181']
stringOfNumbers = "120, 150, 75" listOfNumbersAsStrings = stringOfNumbers.split(",") firstNumberInListAsAString = listOfNumbersAsStrings[0] firstNumberInListAsANumber = int(firstNumberInListAsAString) print(stringOfNumbers) print(listOfNumbersAsStrings) print(firstNumberInListAsANumber + 1) print(firstNumberInListAsAString + 1) # WRONG - can't add 1 to a string, causes an error message the above produces as output: 120, 150, 75 ['120', ' 150', ' 75'] 121 Traceback (most recent call last): ... TypeError: Can't convert 'int' object to str implicitly
print("The Unicode number for 'p' is:", ord('p')) print("The character for the Unicode number 112 is:", chr(112)) print("The character for the Unicode number 63 is:", chr(63)) print("The Unicode number for '?' is:", ord('?')) the above produces as output: The Unicode number for 'p' is: 112 The character for the Unicode number 112 is: p The character for the Unicode number 63 is: ? The Unicode number for '?' is: 63
listOfCharacters = ['h', 'e', 'l', 'l', 'o', ' ', 't', 'h', 'e', 'r', 'e'] sameThingAsAString = "".join(listOfCharacters) print(listOfCharacters) print(sameThingAsAString) the above produces as output: ['h', 'e', 'l', 'l', 'o', ' ', 't', 'h', 'e', 'r', 'e'] hello thereThis example shows only a little of the power of join. Please feel free to ask your instructor or csse120-staff@rose-hulman.edu if you want a complete explanation of join.