我想先打个招呼,然后你得打个招呼,然后在那儿打个招呼。如果你不打,它会告诉你打个招呼。
hello = input('Hello') def hiOrHey(hello): if hello == 'hi': if True: print("Hey there!") else: print("SAY HI")
但是,它不起作用,它只是说“你好!”,并留下一个空行。
你在叫你的函数hiOrHey吗。
如果不是,那就叫它。
def hiOrHey(hello): if hello == 'hi': print("Hey there!") else: print("SAY HI") hello = input('Hello') hiOrHey(hello)
def hiOrHey(hello): print("hello") if hello == 'hi': print("Hey there!") else: print("SAY HI") hiOrHey(hello)
文件名
if True
以下内容将帮助您开始。
def hiOrHey(hello): if hello.lower() == 'hi': # Check if hello in lowercase matches hi print("Hey there!") else: print("SAY HI") hello = input('Say Hi: ') hiOrHey(hello) # Call your function, passing variable hello