min() arg is an empty sequence

2024/10/5 15:37:10

I created a function that consumes a list of values and produces the average. However it only works when I use integer values. I get the following error when I make the values into floats:

min() arg is an empty sequence

What's wrong here. If it works for integers, why not floats. How do I fix this?

Answer

As the error suggests, you passing in an empty sequence to you min call. What that means is if for example you have an elem_list and are calling min(elem_list), the list is currently empty [] and is erroring. Whatever your calling min on is currently empty.

https://en.xdnf.cn/q/119953.html

Related Q&A

Removing last words in each row in pandas dataframe

A dataframe contains a column named full_name and the rows look like this: full_name Peter Eli Smith Vanessa Mary Ellen Raul Gonzales Kristine S Lee How do I remove the last words and add an additi…

Object of type function has no len() in python

I have been searching for a solution for this error for a while but the solutions that have helped others have not been much help for me.Here is the code that Ive wrote.def main():while True:userInput(…

My If condition within a while loop doesnt break the loop

Struggling to get my code for the final room to finish the text-based game assigned to me. I essentially want the player to be forced to get all 6 items prior to entry. Any help is greatly appreciated.…

Adding strings, first, first + second, etc

Program has to be able adding strings from the list and output them in sequence but in the way: 1 string 1 + 2 string 1 + 2 + 3 string ...def spacey(array):passe = ""i = ""m = []for…

Store Variables in Lists python

So I have tried to do this, and I think its clear what I want, I want to store the message variables that I have made in a List and then use this for printing, I wonder why does this not work?items = …

How can I kill the explorer.exe process?

Im writing a script which is meant to kill explorer.exe. I searched a bit about it and the best answer Ive seen uses the taskkill command. I tried it, but when I run it on my computer it says it worked…

A presence/activity set command?

So, I was wondering if there could be a command I could write that allows me to set the bots presence and activity (ex. ~~set presence idle or ~~set activity watching "people typing ~~help") …

Inverted Index in Python not returning desired results

Im having trouble returning proper results for an inverted index in python. Im trying to load a list of strings in the variable strlist and then with my Inverse index looping over the strings to return…

Remove white space from an image using python

There are multiple images that have white spaces that I need to remove. Simply crop the image so as to get rid of the white spaces Heres the code I tried so far (this is a result of search) import nump…

How to calculate the ratio between two numbers in python

I have to calculate the ratio between 0.000857179311146189 and 0.026955533883055983 but am unsure how to do this other than by dividing the two numbers. Is it possible to calculate this with the result…