Home > Enterprise >  It says that the problem in my cde is with using int() function, can someone please correct this
It says that the problem in my cde is with using int() function, can someone please correct this

Time:08-14

item1 = input=("Enter the price of item 1: ")
item2 = input=("Enter the pricr of item 2: ")
cart=[item1, item2]
total=0
for price in cart:
    total = price
    print(f"Total={total}")

#it says there is a problem with the int() function

CodePudding user response:

When you use item1 = input = ("Something"), Then item1 is a string with value "Something". Therefore, it is not accepting any input value.

item1 = input("Enter the price of item 1: ")
item2 = input("Enter the pricr of item 2: ")
cart=[item1, item2]
total=0
for price in cart:
    total = int(price)
    print(f"Total={total}")
  • Related