Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

variable assignment added #5

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

songWukong
Copy link
Collaborator

No description provided.

@@ -1,8 +1,11 @@
from calc import *

class Interpreter:

__variables = {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we are using this for variable assignment why not store the corresponding values into the dictionary itself and then we can access each of values as keys.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do actually. And we can access values via keys like so:
variables = {'var1' : val1, 'var2' : val2}
print variables[var1]
output: val1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants