Ask coding questions

← Back to all posts
Rounding (in python)

I am trying to round 4 numbers in a list with the round() function, but it is not working. Lines 142 and 149 are where I am trying to round it (I have it in two places). My numbers are randomly changed to simulate the fluxuations in the market, but when they come out, they are decimals. I want to then change each number to not have a decimal, but just an interger.

Answered by Spacecraft [earned 5 cycles]
View Answer

I'm not sure exactly what is going on here, but it looks like you are not actually setting the variable with the round function.
Line 142-
IS: round(prices[i])
SHOULD BE: prices[i] = round(prices[i])

Line 150-
IS: round(i)
SHOULD BE: prices[i] = round(i) ??? Not exactly sure what you are doing here, but hopefully you get the idea. Calling the function all by itself doesn't do anything if it isn't assigned to a variable.


Thank you so much! It [email protected]