Chongqing University of Posts and Telecommunications Python Homework 2. Caesar Encryption ---- (the fourth homework)

Article Directory


Original title

Insert picture description here


Code

str = list(input().split(' ',1));tmp = str[1];ret = ''
for i in tmp:
    if i.isalpha():
        character = ord(i)+int(str[0])
        if(i.islower() and character > ord('z') or i.isupper() and character > ord('Z')):character -= 26
        ret += chr(character)
    else:ret += i
print(ret)

Guess you like

Origin blog.csdn.net/qq_37500516/article/details/115239804