Unboundlocalerror: Local Variable 'core_prices' Referenced Before Assignment
i use a function calculate servers prices so i made a function which retrieve a defalut prices of a server components and calculate server price for each server exsit in my DB but
Solution 1:
When your SELECT * FROM examples_calculationsmetric
doesn't return any results, Core_prices
is never set (nor are the other variables in that loop).
Python names do not exist until assigned to, so if results
is an empty list, the names inside the for
loop never get assigned to and thus do not exist by the time you loop over results1
later on.
You could set default values for those names as a work-around:
RAM_prices = 0Core_prices = 0HHD_SATA_prices = 0HHD_SSD_prices = 0CPU_priority = 0Avaibility = 0
to at least ensure that they are defined.
Post a Comment for "Unboundlocalerror: Local Variable 'core_prices' Referenced Before Assignment"