بتل کد Battle Codeدارد باز می‌شود…

Kind, Unkind or Can't Tell چالش 4 از جلسه‌ی 33، متوسط

امتیاز جمله‌ای که با input می‌آید حساب و چاپ شده. حالا برچسب بزن: اگر total > 0 بود kind، اگر total < 0 بود maybe unkind، وگرنه can't tell. برای what a great idea:
score: 2
kind

WEIGHTS = {"great": 2, "fun": 2, "love": 2, "nice": 1, "cool": 1, "kind": 2,
           "boring": -2, "bad": -1, "stupid": -3, "ugly": -2, "hate": -3, "slow": -1}

sentence = input().lower()
total = 0
for word in sentence.split():
    total += WEIGHTS.get(word, 0)
print("score:", total)

راهنما و جواب این چالش · برگشت به درس جلسه‌ی 33: خوب یا بد؟ · چالش بعدی: The Not Rule

بیشتر بخوان: دیکشنری در پایتون: آموزش کامل کلید و مقدار با مثال