python编写密码

编程 电脑密码
要求:
使用 input() 函数获取刘星的输入,它将作为参数 num 传入函数 guess_password(),请你完善代码使下列规则成立;

1.只支持 1-999999 内的数字,超过范围时,屏幕输出 请输入 1-999999 以内的数字;

2.当猜到的数字为 666 时,屏幕打印 哼,以为喊我六我就能给你开电脑了吗?;

3.当猜到数字为 768145 时,屏幕打印 密码猜对了,玩一会就去学习吧;

4.输入其他数字时,屏幕输出 密码不正确,快去学习吧。

根据以上条件,补全代码

def guess_password(num):
result = int(input('刘星猜测的电脑密码是?:'))

guess_password(result)



可以参考以下代码,如果对你有帮忙,麻烦采纳下,谢谢~~~

def guess_password(num):
    if num < 1 or num > 999999:
        print("请输入1-999999以内的数字")
    elif num == 666:
        print("哼,以为喊我六就能给你开电脑了吗?")
    elif num == 768145:
        print("密码猜对了,玩一会就去学习吧")
    else:
        print("密码不正确,快去学习吧")


num = int(input('刘星猜测的电脑密码是?:'))
guess_password(num)