Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Dictionary View Object in Python | 3

Welcome to EasyCoding with Ammara
Subscribe My Coding Channel:
https://www.youtube.com/channel/UC8UsfNYmbKiRJvI9ZhhApEw?view_as=subscriber

Subscribe my personal YouTube Channel:
https://www.youtube.com/channel/UCa93R2oNQMuX0fOKa9eV4zg?view_as=subscriber

Let's Start
Description:

In this post, I am going to show you how to use dict in python in pycharm tool. In dictionary view, we store data using keys like dict(a=1). In this example, a is key and 1 is value. Also we learn how to delete specific key or value from dict.


1) data = dict(a=1,b=2,c=3)    //define data
keys = data.keys()              // get keys (a,b,c)
values = data.values()      // get values (1,2,3)

n = 0
for val in values:         //for loop
 n += val                // increment n=n+val
print(n)                 //print n
print(keys)           
print(values)

output:

6
dict_keys(['a', 'b', 'c'])
dict_values([1, 2, 3])

To delete specific key or value:

data = dict(a=1,b=2,c=3)
del data['a']
print(data)             //   {'b': 2, 'c': 3}




This post first appeared on AR Programming, please read the originial post: here

Share the post

Dictionary View Object in Python | 3

×

Subscribe to Ar Programming

Get updates delivered right to your inbox!

Thank you for your subscription

×