Skip to content

Commit

Permalink
reordered code to match project
Browse files Browse the repository at this point in the history
  • Loading branch information
pjbRPF committed Dec 18, 2024
1 parent 519ce1d commit 2e8a4cb
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions en/code/secret-messages-complete/main.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
#!/bin/python3

alphabet = 'abcdefghijklmnopqrstuvwxyz'
newMessage = ''

message = input('Please enter a message: ')

key = input('Enter a key (1-26): ')
key = input('Please enter the key: ')
key = int(key)
new_message = ''

for character in message:
if character in alphabet:
position = alphabet.find(character)
newPosition = (position + key) % 26
newCharacter = alphabet[newPosition]
newMessage += newCharacter
else:
newMessage += character
message = input('Please enter a message: ')

print('Your new message is: ', newMessage)
for character in message:
if character in alphabet:
position = alphabet.find(character)
new_position = (position + key) % 26
new_character = alphabet[new_position]
new_message += new_character
else:
new_message += character
print(new_message)

0 comments on commit 2e8a4cb

Please sign in to comment.