Below code creates a dictionary with three elements, where the keys are the names "John", "Jane", and "Jim", and the values are the ages 25, 30, and 35, respectively. The code then uses a for
loop to iterate over the elements in the dictionary and outputs each element as a row in the HTML table. The HTML table has two columns for the array key and the index value.
Code Block |
---|
array = {
"John": 25,
"Jane": 30,
"Jim": 35
}
table = "<table><tr><th>Array Key</th><th>Index Value</th></tr>"
for key, value in array.items():
table += "<tr><td>{}</td><td>{}</td></tr>".format(key, value)
table += "</table>"
print(table)
|
...