我正在创建一个将几个列表合并为一个字符串的函数,并且遇到以下错误。
Traceback (most recent call last):
File "TraditionalRoute\BioKeywords.py", line 65, in <module>
print(PrintKeyDefs())
File "TraditionalRoute\BioKeywords.py", line 30, in PrintKeyDefs
defsTwo = dict(map(None, letters, defsOne))
TypeError: 'NoneType' object is not callable
我的代码如下:
# print keyword and three definitions, one of which is the correct definition
def PrintKeyDefs():
print('\nRandomly selected keyword:',SelectKeyword(),'\n')
# definitions below
defsOne = []
defsOne.append(keywords[ChosenKeyword]) # choosing the keyword
RandDefCount = 0
while RandDefCount < 2: # adding two random keywords to the list
defsOne.append(keywords[random.choice(words)])
RandDefCount += 1
random.shuffle(defsOne) # randomizing the keywords
letters = ['A) ','B) ','C) ']
defsTwo = dict(map(None, letters, defsOne)) # trying to put them together in a dict. the problem is here
defsThree = ''
defsThree += '\n'.join(defsTwo) # changing to a string
return defsThree
任何人都可以提出一个可能的解决方案,因为我已经花了很长时间在这方面并且还没有弄清楚。谢谢。
编辑:忘了提到我正在使用 Python 3