题解 | 密码游戏
密码游戏
https://www.nowcoder.com/practice/36641ab168664384aff798ba7ce34bc1
str1 = input()
#将读到的数字都变成整数格式
a = int(str1[0])
b = int(str1[1])
c = int(str1[2])
d = int(str1[3])
#得到它们+3 除以9之后的余数
a2 = (a+3)%9
b2 = (b+3)%9
c2 = (c+3)%9
d2 = (d+3)%9
#sum是最终得到的四位数,之后再按照固定格式输出
sum = c2*1000+d2*100+a2*10+b2
print(f"{sum:04d}")
