Bỏ qua điều hướng
PROMPTLIB × P2SThư viện prompt + skill
Về thư viện Prompt
Minh họa công nghệ cho Sửa lỗi IndexError trong Python
PROMPTCode

Sửa lỗi IndexError trong Python

Tìm và sửa lỗi `IndexError: list index out of range` trong đoạn mã Python.

Prompt gốc

Đoạn mã Python sau đang gây ra lỗi `IndexError: list index out of range`. Hãy xác định nguyên nhân và sửa lỗi để hàm chạy đúng: `def get_element(my_list, index): if index <= len(my_list): return my_list[index] else: return 'Index out of bounds'`
Lưu