Apr-21-2019, 10:28 PM
Dear Programmers,
I hope you are having a wonderful sunday:
# the Program is meant to display the info from the dictionary, but instead is displaying letters.
Could you please help me solve the issue in my code.
I hope you are having a wonderful sunday:
# the Program is meant to display the info from the dictionary, but instead is displaying letters.
Could you please help me solve the issue in my code.
mydata = {'Stock1': [125, 772.88, 941.53], 'Stock2': [85, 56.60, 73.04], 'Stock3': [400, 49.58, 55.74], 'Stock4': [235, 54.21, 65.27], 'Stock5': [150, 124.31, 172.45]} headers = ["Stock Symbol", "No Shares", "Purchase Price", "Current Value"] separator1 = '+----------------+-------------+------------------+-----------------+' separator2 = '+================+=============+==================+=================+' print("\nStock Ownership") print(separator1) print('| {:14} | {:11} | {:16} | {:15} |'.format(*headers)) print(separator2) for key, value in mydata.items(): print('| {:14} | {:11} | {:16} | {:15} |'.format(*key, *value))
Output:Stock Ownership
+----------------+-------------+------------------+-----------------+
| Stock Symbol | No Shares | Purchase Price | Current Value |
+================+=============+==================+=================+
| S | t | o | c |
| S | t | o | c |
| S | t | o | c |
| S | t | o | c |
| S | t | o | c |