文字列をリスト内の項目と照合する機能があり、リスト項目のインデックス番号を返しますマッチです。以下のように:TypeError:whileループで+: 'NoneType'および 'int'のサポートされていないオペランドタイプ
def get_int(get_wd, get_list):
for i, j in enumerate(get_list):
if j == get_wd:
get_i = i
return get_i
main関数でwhileループは、機能上からの戻り整数を得ることがあります:
>> li_a = li_a[pos + 1:]
>> TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'
:
get_wd = []
x = 0
candi = []
while len(li_a) > 0:
iter_a = iter(li_a)
srh_time = len(li_a)
while srh_time > 0:
temp = next(iter_a)
if temp in li_words:
candi.append(temp)
else:
pass
srh_time = srh_time - 1
max_len = max(len(s) for s in candi)
extr_wd = list(set(s for s in candi if len(s) == max_len))
pos = get_int(extr_wd, li_a) ##Calling the function##
get_wd.append(extr_wd)
li_a = li_a[pos + 1:]
私は、このエラーメッセージが出てい
私には何かアドバイスがありませんか?
posは何に等しくない:
あなたはインデックス
を見つけるため
.index
を使用することができますがget_int
メソッドをリファクタリングtoは 'NoneType'です。また、元の関数に 'get_i'は必要ありません。 'j' == get_wd:' –私はあまりにも前にそれを試みたが、同じメッセージを持っている。 :( – htetmyet