print ("Hello, User :)")
def search():
answer = phrase.find(search)
return answer
y = "Y"
while y == "Y":
phrase = input("Please enter a phrase any phrase: ")
print ("Thank you User - the phrase you entered reads as follows: ")
print (phrase)
search = input("Please enter one of the words of the phrase you just entered, or some consecutive characters from that phrase, and I will search for them: ")
print ("Thank you, User")
print ("Your word or characters are located at the following index location: ")
search()
#print (answer)
y = input("Thanks for playing. Would you like to play again(Y/N)?: ")
else:
print ("Goodby, User")
希望有人能帮助为什么我的函数定义不能被调用。
函数名不能与变量名相同。只需search
像这样更改变量名称:
search_ = input("Please enter one of the words of the phrase you just entered, or some consecutive characters from that phrase, and I will search for them: ")
search()
此外,如果您希望打印出结果,请调用如下函数:
print(search())
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句