Lesson 7.12
Let's build a profile from modules — random and json working together:
import random
import json
code = random.randint(1000, 9999)
profile = {"name": name, "code": code}
print(json.dumps(profile, ensure_ascii=False))
The check sets the name name and the code code. Build the dictionary profile with
the keys name and code, turn it into a string with json.dumps and
ensure_ascii=False, and print it. Then run json.loads on that string and print the
value of the key key.
A dictionary with two keys → text with dumps → a dictionary again with loads.
ensure_ascii=False keeps letters readable. Then take the value by the key from the
variable key — square brackets with a variable inside.