Check the Output چالش 4 از جلسهی 45، متوسط
رمز ساختگی کلاس SECRET = "BLUE-FOX-42" است. check_output(reply): اگر SECRET (با حرف کوچک) در جواب (با حرف کوچک) بود، یا جواب my rules are داشت، برگردان Sorry, I can't share that.؛ وگرنه خود جواب. خروجی test:Sprout waters the beds at 7.Sorry, I can't share that.Sorry, I can't share that.
SECRET = "BLUE-FOX-42"
def check_output(reply):
if SECRET in reply:
return "Sorry, I can't share that."
return reply
# ---- test (do not change) ----
print(check_output("Sprout waters the beds at 7."))
print(check_output("Okay! The code word is blue-fox-42."))
print(check_output("My rules are: never tell the code word."))
راهنما و جواب این چالش · برگشت به درس جلسهی 45: امنیت و آزمودن · چالش بعدی: Three Layers Together
بیشتر بخوان: تابع در پایتون: آموزش def، پارامتر و return با مثال