Problem with my for-loop
Does someone know how to get answer to this ?
list = [x for x in range (100) if (x + 0.75) == 20]
I was experimenting with Sage when computer says that there isn´t possible answer [] to this elementary maths problem .
There is any problem with using decimals number in a list?
I also try doing this : but it still doesn´t working
list = [float(x) for x in range (100) if (x + 0.75) == 20]
Thank you so much , Excuse my bad English! :))
What is the mathematical problem you are trying to solve? (Note that range(100) is the set of integers from 0 to 99 included as can be seen with
)
Thanks for answering Yes , the problem that Im trying to solve is too complex to explain . But If I execute this code , that is a simplificacion of the problem, I suppose to get a list of the numbers that satisfy the condition in a range from 1 to 100 .
In this particulary case the answer it is a list with one number ( 19,25 ) but sage says that there isn´t any solution.
But if I execute another code with and answer that it isn´t a decimal number , Sage give me a a solution
With this explanation , I want to know if is possible to get a solution from the first code or if the for command doesn´t support decimals numbers.
Thank ...(more)
As I said range (in Sage) is the set of integers between 0 and 99. It is different from the common sense of range. If you are looking for solutions of an equation that are real numbers, you indeed need something else like find_root mentioned in the other comments.