"orange"
ユーザーから提供された単語 (例: ) を、次のようなテキスト ファイルにある単語のリストと比較しようとしています。
menu.txt
apple
banana
orange
grape
mango
ユーザー入力はeasygui.enterbox
. 文字列を比較するのに苦労しているため、期待した結果が得られません。これが私のコードです。
import easygui
count = 0
dish = easygui.enterbox("enter your favourite dish:")
with open("menu.txt") as f:
content = f.readlines()
for item1 in content:
if item1 == dish :
easygui.msgbox("order taken.thankyou")
count = count + 1
continue
if count == 0 :
easygui.msgbox("plz order some other item")