0
Satchel = {'rope': 1, 'torch': 6, 'gold coin': 42, 'dagger': 1}
def displayInventory(inventory, leftWidth, rightWidth):
    print('INVENTORY'.center(leftWidth + rightWidth, '-'))
    for k, v in inventory.items():
        print(k.ljust(leftWidth, '.') + str(v).rjust(rightWidth))
        item_total = int(item_total) + int(v)
        print('Total number of items: ' + str(item_total)

displayInventory(Satchel, 15, 6)

I receive a syntax error when I call the displayInventory function. I am having trouble determining what is wrong with this code.

2
  • 1
    What's the exact error? Commented Feb 20, 2016 at 22:21
  • Please proofread your code more carefully in the future. Commented Feb 20, 2016 at 22:50

1 Answer 1

2

The last call to print in your function is missing a closing parenthesis. In addition, in the code you are showing you are using the name item_total before defining it.

In general: if you get a weird syntax error - look at the previous line.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.