ما هو الخطا هنا ؟

def choose_cave():

while True:
  cave = input("which cave will you choose ?.")
if cave == 1:
    print("you find the dragon .")
  elif cave == 2:
   print("this cave will lead you to the outside!")
   else :
       print("wrong!choose one of the two caves.")
يرجى الدخول لحسابك أو تسجيل حساب لتستطيع إضافة تعليق
حساب جديد دخول

التعليقات

cave = int(input("which cave will you choose ?."))

لكن انا لما بعمل للكود check بيجيلى الغلط ف السطر ده elif cave == 2: وانا مش فاهمه ليه هو غلط ؟

Alwalid أضف ردا

بسبب المسافات الموجودة في بداية السطر .. يجب ان يكون elif و else علي نفس مستوي بداية جملة الشرط IF