Question:
When searching a ReplDB with dictionaries inside of dictionaries, the results display as a list by letter instead of by word (I hope that makes sense). I was able to create a minimal Repl that reproduces my problem so that you don’t have to debug a large amount of code.
How can I get my expected result? I find this data structure for the DB very useful for my program but I can’t figure out why it puts each letter as its own item in the list.
Expected result of program:
['joe', 'steve']
Actual result:
['j', 'o', 'e', 's', 't', 'e', 'v', 'e']
Repl link:
https://replit.com/@CoderElijah/ReplDB-Problems#main.py (I think you have to fork it for it to work since it’s a DB.)
from replit import db
db["test"] = {}
db["test"].update({"1":{"name":"joe"}, "2":{"name":"steve"}})
def search(numbers:list):
results = []
for result in numbers:
results += db["test"][result]["name"]
return results
print(search(["1","2"]))