input

1 فروردين ۱۴۰۲

من میخوام از کاربر یک ورودی بگیرم که یا no  یا yes  باشه چجوری میتونم همچین محدودیتی به کاربر بدم؟

243

1 پاسخ
  • دانیال آذرپناه7 فروردين ۱۴۰۲
    سلام و وقت بخیر
    این تیکه کد رو بررسی کنید لطفا
    def get_user_input():
        user_input = input("Enter yes or no: ")
    
        if user_input == "yes" or user_input == "no":
            print(f"The answer is {user_input}")
        else:
            get_user_input()
    
    get_user_input()