“Jak zrobić pytanie tak lub nie w Pythonie” Kod odpowiedzi

Zadaj pytanie o Python

Question = input("your question")
if Question == ("yes")
	print ("well done")
elif Question == ("no")
	print ("try again")
Long Lion

Jak zadać pytanie tak lub nie na Python

answer = input("Enter yes or no: ") 
if answer == "yes": 
    # Do this. 
elif answer == "no": 
    # Do that. 
else: 
    print("Please enter yes or no.") 
Juji_Wuji

Jak zrobić pytanie tak lub nie w Pythonie

def question():
    i = 0
    while i < 2:
        answer = input("Question? (yes or no)")
        if any(answer.lower() == f for f in ["yes", 'y', '1', 'ye']):
            print("Yes")
            break
        elif any(answer.lower() == f for f in ['no', 'n', '0']):
            print("No")
            break
        else:
            i += 1
            if i < 2:
                print('Please enter yes or no')
            else:
                print("Nothing done")


question()
Joe Stables

Odpowiedzi podobne do “Jak zrobić pytanie tak lub nie w Pythonie”

Pytania podobne do “Jak zrobić pytanie tak lub nie w Pythonie”

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu