Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Execute Python-3 Online

# Hello World program in Python
    
dict = {
    "key1":"val1",
    "key2":"val2",
    "key3":"val3",
}

dict['key4'] = 'val4'

# dict1 = dict.copy();
# print(dict1);


# seq = ('name', 'age')
# dict2 = dict.fromkeys(seq)
# print ("New Dictionary : %s" %  str(dict2))


# dict2 = dict.fromkeys(('name1', 'age1'),[100,200])
# print ("New Dictionary : %s" %  str(dict2))


print(dict.get('key21'));

dict.setdefault('key5','val5')

print(dict.items());

dict3 = {
    "key6":"val6",
    "key1":"val_1",
    "key7":"val7",
    
}

dict.update(dict3)

print(dict);

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.