亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

TypeError:列表索引必須是整數或切片,而不是 str

TypeError:列表索引必須是整數或切片,而不是 str

慕俠2389804 2022-11-01 14:45:03
過去兩天我一直在嘗試解決此錯誤,但我無法解決。我必須將值(這是一個列表)傳遞給函數,但它說:Typerror :list indices must be integers or slices and not str.這是我的代碼:def input_execute(board, position, mark):    board[position] = markposition = input('enter the position')input_execute(board_items, position, 'x')輸出:enter the position:5如果我輸入它顯示的位置:Typerror :list indices must be integers or slices and not str.
查看完整描述

1 回答

?
慕蓋茨4494581

TA貢獻1850條經驗 獲得超11個贊

下面的行返回字符串

position=input('enter the position')

現在將此行更改為

position=int(input('enter the position : '))


查看完整回答
反對 回復 2022-11-01
  • 1 回答
  • 0 關注
  • 90 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號