how do i add a new number/string in an dictionary?

0 Sky Fied · May 17, 2015
how do i add a new number/string in an dictionary? i use Python 3.4.3 and i need to know the method (if any) to add a new number/string in an dictionary without to add it by myself... by the way, my english not perfect so yeah...

im quite new to python but i have programmed/coded in C++ and java, and im trying to make a quite complicated calculator...

Post a Reply

Replies

Oldest  Newest  Rating
0 Colonel Panic · May 17, 2015
you just assign it

>>> something = {'foo':'bar', 'x':1}
>>> print something
{'x': 1, 'foo': 'bar'}
>>> something['foo']
'bar'
>>> something['y'] = 2
>>> print something
{'y': 2, 'x': 1, 'foo': 'bar'}
  • 1

Python

106,978 followers
About

This section is all about snakes! Just kidding.

Links
Moderators
Bucky Roberts Administrator