hi how can i display each value from the dictionary below
product = {'barcode': [123, 456], 'Name': ['Milk', 'Bread'], 'Price': ['2', '3.5'], 'weight': ['2', '0.6']}
i want output as:
123 Milk 2
456 Bread 3.5
hi how can i display each value from the dictionary below
product = {'barcode': [123, 456], 'Name': ['Milk', 'Bread'], 'Price': ['2', '3.5'], 'weight': ['2', '0.6']}
i want output as:
123 Milk 2
456 Bread 3.5
You can use pandas
.
import pandas as pd
product = {'barcode': [123, 456], 'Name': ['Milk', 'Bread'],
'Price': ['2', '3.5'], 'weight': ['2', '0.6']}
df = pd.DataFrame(product)
for _, row in df.iterrows():
print(row['barcode'], row['Name'], row['Price'])
123 Milk 2
456 Bread 3.5
Edit:
Using pure Python:
product = {'barcode': [123, 456], 'Name': ['Milk', 'Bread'],
'Price': ['2', '3.5'], 'weight': ['2', '0.6']}
for tup in zip(*list(product.values())[:-1]):
print(*tup)
123 Milk 2
456 Bread 3.5