【发布时间】:2018-04-11 02:30:22
【问题描述】:
def isWordGuessed(secretWord, lettersGuessed):
for char in secretWord:
if char not in lettersGuessed:
print('_',end=' ')
else:
print(char,end=' ')
print(isWordGuessed('apple', ['e', 'i', 'k', 'p', 'r', 's']))
输出为_pp_eNone
我希望我的输出为_pp_e,同时仍使用打印函数调用该函数。
我该怎么办?
【问题讨论】:
-
对所有的混乱感到抱歉。我确实在 30 秒前加入了这个网站。
-
好的,我为你修好了。当我现在运行代码时,我得到
_ p p _ e。你期待不同的东西吗? -
你是怎么做到的。另外我想知道你是否可以在使用 print(isWordGuessed('apple', ['e', 'i', 'k', 'p', 'r', 's']))
标签: python python-3.x function printing return