Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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}")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading