完整代码:`
在这里插入代码片
```import random
print("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --密码猜猜猜-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --")
print("正确密码由四个互不相同的大写字母组成,猜猜看呐")
letterList = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
passwordList = []
count = 0
gjr = ""
while True:
index = random.randint(0,len(letterList)-1)
letter = letterList[index]
passwordList.append(letterList[index])
letterList.pop(index)
count += 1
if count == 4:
break
while True:
user = input("请输入密码:")
userList = list(user)
if len(userList) == 4:
posCorrect = 0
if passwordList[0] == userList[0]:
posCorrect += 1
if passwordList[1] == userList[1]:
posCorrect += 1
if passwordList[2] == userList[2]:
posCorrect += 1
if passwordList[3] == userList[3]:
posCorrect += 1
pos_right = ("位置对了:" + str(posCorrect))
letterCorrect = 0
if userList[0] in passwordList:
letterCorrect += 1
if userList[1] in passwordList:
letterCorrect += 1
if userList[2] in passwordList:
letterCorrect += 1
if userList[3] in passwordList:
letterCorrect += 1
letter_right = ("字母对了:" + str(letterCorrect))
if userList == passwordList:
print("猜对了,你真棒")
break
else:
print(pos_right + letter_right)
else:
print("别乱输")
`



