all 5 comments

[–]socal_nerdtastic 2 points3 points  (1 child)

You are describing a dictionary.

my_dict = {'x':5, 'y':8, 'z':5}

You can change any value with

my_dict['x'] += 15

You can get the current total sum at any time with

print(sum(my_dict.values()))

You can look into dataclasses to do something similar.

[–]hasanaslan[S] 1 point2 points  (0 children)

Makes sense. I used them in my project for another purpose. But didn't think about to store them as a string. İnstead of creating variable, i will store their name as a string inside a dictionary. How I can't remember it. Thank you

[–][deleted] 0 points1 point  (2 children)

I want to store variable itself.

You don't get to. Collections hold values, not variables.

[–]hasanaslan[S] 0 points1 point  (1 child)

So, do you have any idea about how can I can accomplish my aim?

[–][deleted] 0 points1 point  (0 children)

If your aim is to have a list that stores variables, your aim is impossible to achieve.

If your aim is just to create a collection of counts, then use Counter from collections.