最初に。私のコード:
UserInput = ("null") #Changes later
def ask_module(param, param2):
elif UserInput == (param):
print(param2)
while True:
UserInput = input()
UserInput = UserInput.lower()
print()
if UserInput == ("test"):
print("test indeed")
ask_module("test2", "test 2")
私はコーディングが得意ではないので、これはおそらく私が本当に間違ったことをしたことです
私はほとんどコードを持っているだけなので、この投稿は少し大げさなようですが、これを機能させる方法はまったくわかりません。
短縮なしのコードは次のようになります。
while True:
UserInput = input()
UserInput = UserInput.lower()
print()
if UserInput == ("inventory"):
print("You have %s bobby pin/s" %bobby_pin)
print("You have %s screwdriver/s" %screwdriver)
elif UserInput == ("look at sink"):
print("The sink is old, dirty and rusty. Its pipe has a bobby pin connected")
else:
print("Did not understand that")
編集:私が求めているものを見るのは難しいかもしれません。
元のコードをどのように短縮できるか疑問に思っています