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

Step 4: Untidy Messages چالش 4 از جلسه‌ی 8، سخت

قدم ۴ از ۴: ربات را برای آدم‌های واقعی آماده کن. پیام را با .strip() و .lower() مرتب کن تا /FOOD هم فهمیده شود، و جواب پیام ناشناخته را این کن: Sorry, I don't know <پیام مرتب‌شده>. Send /help to see my commands. برای Hello: Sorry, I don't know hello. Send /help to see my commands.

import bot
text = input()
if text == "/start":
    print("Hi! I am School Bot. Send /help to see what I know.")
elif text == "/schedule":
    print("Today: Math, Science, Art")
elif text == "/food":
    print("Today's lunch: rice and chicken")
elif text == "/exam":
    print("Next exam: Math, on Sunday")
elif text == "/help":
    print("Commands: /schedule /food /exam")
else:
    print("I don't know that yet. Send /help.")

راهنما و جواب این چالش · برگشت به درس جلسه‌ی 8: پروژه: ربات راهنمای مدرسه

بیشتر بخوان: شرط if، elif و else در پایتون: آموزش کامل با مثال