Answer the question
In order to leave comments, you need to log in
How to make the numbers from the dictionary sum up after iteration and parsing?
After iteration and parsing, it does not sum up the numbers, but either displays only the last one, or outputs each from a new line, or after "while True" infinitely sums and gives the error "TypeError: unsupported operand type(s) for +=: 'float' and ' NoneType'"
def searcher(url):
rs = requests.get(url)
m = re.search(r'var line1=(.+);', rs.text)
data_str = m.group(1)
data = json.loads(data_str)
cost =data[-1]
x = cost[1]
return float(x)
def total_cost():
average_costs = 0
for average_cost in CSGO_Stickers_PGL_Major_Stockholm_2021.keys():
average_costs += CSGO_Stickers_PGL_Major_Stockholm_2021[average_cost]
for a,i in CSGO_Stickers_PGL_Major_Stockholm_2021_Current_Cost.items():
cumma = 0
cumma += searcher(i)
print('Всего инвестировал в PGL Major Stockholm 2021', '%.2f' % average_costs+'$ с разницей', cumma)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question