0
如何使if
語句具有兩個值,即同義詞即「display」和「screen」,然後是and
和另一個字符串,如「broken」。這個想法是,只有在出現「顯示」,「破碎」或「屏幕」和「破碎」時纔會輸出。不知道如何在if語句中編寫或和語句
我曾嘗試:
def issuesection():
issue = input("Type in your issue in a sentence and we will try out best to help you with a solution: ")
if "display" or "screen" in issue and "broken" in issue:
print('WORKED')
else:
print("FAIL")
這是最緊湊的方式嗎? –
可能是的,儘管代碼最小化是一個非常困難的問題。 –
你也可以做任何(x [in [「display」,「screen」]中的x),這個例子比較長,但是你可以在其他位置創建列表和/或添加更多的東西所以更具可擴展性 – Copperfield