我的家庭作业需要有人帮我写这段Python代码

我的家庭作业需要有人帮我写这段Python代码,python,for-loop,while-loop,Python,For Loop,While Loop,到目前为止,我有这个 user_input = 0 safe_code = 20201 attempts = 0 while attempts < 3: print("enter the code") user_input = int(input()) if (user_input = 20201): print("safe opened") else: print(input(&

到目前为止,我有这个

user_input = 0
safe_code = 20201

attempts = 0

while attempts < 3:
    print("enter the code")

    user_input = int(input())
    if (user_input = 20201):
        print("safe opened")
    else:
        print(input("incorrect try again "))

    attempts = attempts + 1

    if user_input == safe_code:
        break

print("safe opened")
user\u输入=0
安全代码=20201
尝试次数=0
当尝试<3时:
打印(“输入代码”)
用户输入=int(输入())
如果(用户输入=20201):
打印(“安全打开”)
其他:
打印(输入(“错误重试”))
尝试次数=尝试次数+1
如果用户输入=安全代码:
打破
打印(“安全打开”)
我需要有关为此提示符编写此程序的帮助:

进入保险箱的代码是20201。编写一个程序,要求用户提供代码。用户只能尝试输入正确的代码3次。如果3次后代码输入不正确,程序应显示“保险箱已锁定”,5次并发出蜂鸣声并结束。如果在3次尝试中正确输入代码,程序应显示“保险箱已打开”3次以及输入错误代码的次数,并发出蜂鸣声并结束

我必须使用while或do-while循环和for循环。使用适当的循环


有人请帮忙

欢迎来到Stack Overflow。请告诉我们你试过什么。因此,这不是一个免费的代码编写服务。这里的目的是让你发布你解决自己问题的尝试,当这些尝试没有达到预期效果时,其他人会提供帮助。看,Stackoverflow不是一个代码编写服务或家庭作业帮助网站。您需要带着一个既可复制又简洁的特定问题来到这里。你自己解决这个问题的方法也是可以期待的。请参阅已添加的代码。。。让我们重新打开并回答。