Q:

Python Syntax Error with test code

This is my code:
ItemName = input("Enter your item name: ")
PricePerPound = float(input("Enter the Price per pound: "))
ItemWeightPounds = float(input("Enter the weight of the item in pounds: "))
ItemWeightOunces = float(input("Enter the weight of the item in Ounces: "))
UnitPrice = (PricePerPound/16)
TotalPrice = (PricePerPound * ItemWeightPounds + ItemWeightOunces/16)
print("The Unit Price for your " + ItemName + " is: $" + UnitPrice)
print("The Total Price for your " + ItemName + " is: $" + TotalPrice)

Traceback (most recent call last):
print("The Unit Price for your " + ItemName + " is: $" + UnitPrice)
TypeError: Can't convert 'float' object to str implicitly

whenever I run it in python I get the above error, can anyone identify the issues with my code? 

A:

You are closing your print-statement too early.
All you want to print has to be between the brackets:
print("The Unit Price for your " + ItemName + " is: $" + str(UnitPrice))
print("The Total Price for your " + ItemName + " is: $" + str(TotalPrice))

You also need to cast your float- and int-objects to string because you can only concatenate (+) string-objects.

