Print the header, then loop through the portfolio printing each line.
def print_portfolio(portfolio):
print("Symbol Amount")
for symbol, amt in portfolio:
print(symbol, amt)
If you want the columns to line up, use a formatting method to specify the column widths:
def print_portfolio(portfolio):
print("Symbol Amount")
for symbol, amt in portfolio:
print(f"{symbol:6} {amt:6}")
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…