index-error

IndexError: list index out of range in Py

IndexError: list index out of range in Py Question: I wrote the python code: def diff_4(x, h, y): """Вычисляет приближенное значение производной с помощью формулы численного дифференцирования для четырех равноудаленных узлов""" return (-y[4] + 8*y[2] – 8*y[1] + y[0]) / (12*h) x = 0.295 # начальное значение x h = 0.002 # шаг интерполяции y …

Total answers: 2

Application keeps crashing and is very laggy: IndexError: index 0 is out of bounds for dimension 0 with size 0

Application keeps crashing and is very laggy: IndexError: index 0 is out of bounds for dimension 0 with size 0 Question: import cv2 import argparse import pandas as pd from ultralytics import YOLO import supervision as sv import numpy as np from supervision.tools.detections import Detections, BoxAnnotator from supervision.tools.line_counter import LineCounter, LineCounterAnnotator from supervision.draw.color import ColorPalette …

Total answers: 2

Python: 'IndexError: list assignment index out of range' from 2d-List

Python: 'IndexError: list assignment index out of range' from 2d-List Question: I got the error IndexError: list assignment index out of range by using the following code: expC = 0 imgC = 0 pictures = [[x for x in range(7)] for y in range(25)] for i in experimentNames: for pictureData in glob.iglob(‘{}/**/*.png’.format(i), recursive=True): img = …

Total answers: 1

IndexError when using Enumerated Indexes in NumPy

IndexError when using Enumerated Indexes in NumPy Question: I am trying to create a fifth-order FIR filter in Python described by the following difference equation (apologies dark mode users but LaTeX is not yet supported on SO): def filter(x): h = np.array([-0.0147, 0.173, 0.342, 0.342, 0.173, -0.0147]) y = np.zeros_like(x) buf_array = np.zeros_like(h) buf = …

Total answers: 1

Why am I getting IndexError: list index out of range error even though I have a proper list

Why am I getting IndexError: list index out of range error even though I have a proper list Question: with open(‘Input’,’r’) as f: while len(a)>0: a=f.readline() #I am going to search for a command to execute in the txt file w_in_line=a.split(‘,’) #words in line command_word_box=w_in_line[0].split()#I took the command word out of the line command_word=str(command_word_box[0]) pat_name=w_in_line[0].replace(command_word,”) …

Total answers: 1

length of list read from a csv varies, depending on when a read is performed

length of list read from a csv varies, depending on when a read is performed Question: I’m trying to write a simple function that reads in a csv and stores its content inside a list and either returns said list formatted or a string containing the information on why the csv is empty. For clarification, …

Total answers: 1

List index out of range in visualize_cv2.py

List index out of range in visualize_cv2.py Question: I want to launch mask-rcnn model from visualize_cv2.py. My goal is train only on 1 element from class_names – person. For this I create class_names1(added full code from this python file for better understanding): import cv2 import numpy as np import os import sys import coco import …

Total answers: 1

Nested loop used in hcf finding code in Python returns IndexError:index out of range

Nested loop used in hcf finding code in Python returns IndexError:index out of range Question: I created a program that will generate the HCF(highest common factor) of the given two numbers. f1 = [] f2 = [] num1 = int(input(“Enter first number:”)) num2 = int(input(“Enter second number:”)) n1 = num1 + 1 n2 = num2 …

Total answers: 3