Python编写输入生成密码程序输出不符合要求如何解决
问题原因
- 自动判分系统会收集程序所有标准输出内容做校验,
input()函数携带的提示文本也会被算作输出内容,原代码的输入提示串打乱了系统预期的输出结构,导致无法识别到目标输出行。
修改方案
删除input()函数内的提示文本即可,原有业务逻辑完全符合需求,无需调整。修改后代码如下:
def userdetails(): words = input() word2 = input() numm = input() pw1 = words+"_"+word2 pw2 = numm+words+numm print("You entered: {} {} {}" .format(words,word2,numm)) print("First password:",pw1) print("Second password:",pw2) print("Number of characters in",pw1,":",len(pw1)) print("Number of characters in",pw2,":",len(pw2)) userdetails()
输出验证
按顺序输入yellow、Daisy、6时,程序输出如下,完全匹配判分要求:
You entered: yellow Daisy 6 First password: yellow_Daisy Second password: 6yellow6 Number of characters in yellow_Daisy : 12 Number of characters in 6yellow6 : 8
内容的提问来源于stack exchange,提问作者LycanSmoke4207
相关产品推荐
相关产品推荐

