Code:
from Crypto.Hash
import SHA256
import os
import random
import string
from operator
import itemgetter
def shaa():
trun = []
clist = {}
for i in range(0, 33554432):
sha = SHA256.new(str(i)).hexdigest()
sha = int(bin(int(sha, 16))[-50: ], 2)
clist[i] = sha
print 'Hashes done.'
clist = sorted(clist.items(), key = itemgetter(1))
for i in range(0, 33554432):
if (clist[i] == clist[i + 1]):
#print string[i], string[i + 1]
print clist[i]
return 1
return 2
result = 2
while (result == 2):
result = shaa()
Suggestion : 2
Last Updated : 25 Jul, 2022
Output:
{
1: 'Geeks',
2: 'For',
3: 'Geeks'
}
Suggestion : 3
Since the key 'cherry' is not present in the dictionary fruit, fruit.get("cherry", 50) returned default value of 50.,In the first item, the key is mango and the value is 40. Similarly, there is a key-value pair in the other two items as well.,fruit.get('mango') returned the value of the key 'mango' of the dictionary fruit.,list(fruit.keys()) returned a list of all the keys and list(fruit.values()) returned a list of all the values of the dictionary fruit.
fruit = {
'mango': 40,
'banana': 10,
'cherry': 20
}
a = {}
fruit = {
'mango': 40,
'banana': 10,
'cherry': 20
}
print(fruit)
mydict = {
'x': [1, 2, 3, 4],
'y': "Hello World",
'z': 4.0
}
print(mydict)
# declaring an empty dictionary fruit = {} # adding key - value pairs to dictionary fruit['mango'] = 40 fruit['banana'] = 10 fruit['cherry'] = 20 print(fruit)
fruit = {
'mango': 40,
'banana': 10,
'cherry': 20
}
print(list(fruit.keys()))
print(list(fruit.values()))