بتل کد 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.

راهنما

خط اول را بکن text = input().strip().lower() و در else از f استفاده کن.

یک جواب درست

import bot
text = input().strip().lower()
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(f"Sorry, I don't know {text}. Send /help to see my commands.")

اول خودت امتحان کن؛ جواب‌های دیگر هم قبول است. برگرد و خودت حلش کن