2019年11月21日 星期四

in list

corrects = ['微軟', 'MICROSOFT', 'MS']   # 正確解答列表
ans=input("比爾蓋茲創立了哪一家軟體公司?")
if ans in corrects:
    print("good")
else:
    print("to bad")

========= 答到對為止
corrects = ['微軟', 'MICROSOFT', 'MS']   # 正確解答列表
#ans=input("比爾蓋茲創立了哪一家軟體公司?")
bn=False
while not bn:
    ans=input("比爾蓋茲創立了哪一家軟體公司?")
    if ans in corrects:
        print("good")
        bn=True
    else:
        print("try again")

沒有留言:

張貼留言