جواب «Phishing Detector» چالش 6 از جلسهی 8
سؤال
(سختتر) برنامهای بنویس که یک پیام با input بگیرد و برای هر کلمهی مشکوک (urgent، click، password، prize، closed) که در پیامِ کوچکشده بود یک امتیاز بدهد. اگر امتیاز ۲ یا بیشتر بود چاپ کن phishing? yes (score 3)، وگرنه phishing? probably not (score 0) (با عدد امتیاز).
راهنما
for w in words: if w in message: score = score + 1. برای چاپ: "phishing? yes (score " + str(score) + ")".
یک جواب درست
message = input().lower()
words = ["urgent", "click", "password", "prize", "closed"]
score = 0
for w in words:
if w in message:
score = score + 1
if score >= 2:
print("phishing? yes (score " + str(score) + ")")
else:
print("phishing? probably not (score " + str(score) + ")")
اول خودت امتحان کن؛ جوابهای دیگر هم قبول است. برگرد و خودت حلش کن