Created
August 20, 2020 16:47
-
-
Save FBosler/17f8da71e8c423e82e2b5c49afd4abd1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import uuid | |
import random | |
import string | |
# GENERATE SAMPLE DATA | |
sample_data = [{ | |
'_id': uuid.uuid4().hex, | |
'name': ''.join(random.choices( | |
[_ for _ in string.ascii_letters], | |
k=10 | |
)), | |
'net_worth': random.randint(10,100)*1000 | |
} for i in range(1000)] | |
random_entry = random.choice(sample_data) | |
print(random_entry) | |
# BUILD THE HASH_TABLE | |
hash_table = { | |
_['_id']:_ | |
for _ in sample_data | |
} | |
# CHANGE ENTRY VIA '_id' | |
hash_table[random_entry['_id']]['net_worth'] = 10000 | |
print(random_entry) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment