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

Python not reading condition inside an IF

noob programmer here. I’m having an issue with python not reading or ignoring what I wrote inside an if, it just goes straight to Exit Code 0. The first if works perfectly, but after the first else it jusr reads until color = input. I’d very much appreciate the help.

chooseS = input('If you need the scanning service type 1, if you need printing press 2. ')
pages = (int(input('How many pages do you need?')))
costT = 0
cost = 0
costS = 0
color = 0

if chooseS == str(1):
    costS = 20
    email = input("Type the email where you want to receive the scanned document.")
    costT = costS*pages
    print("That would be " + str(costT) + " colones. You will receive it at the following adress: " + email + ".")
else:
    if chooseS == str(2):
        color = input("If you need it printed in color type 1. If you need black and white type 2. ")
        if color == 1:
            paper = input("Regular paper: type 1. Film paper:  type 2. Sticker paper: type 3.")
            if paper == 1:
                cost = 25
                costT = int(pages) * cost
                print("That would be: " + str(+costT) + " colones.")
            if paper == 2:
                cost = 250
                costT = int(pages) * cost
                print("That would be: " + str(+costT) + " colones.")
            if paper == 3:
                costo = 300
                costoT = int(pages) * cost
                print("That would be: " + str(+costT) + " colones.")
        if color == 2:
            papel = input("Regular paper: type 1. Sticker paper: type 2. ")
            if paper == 1:
                cost = 15
                cost = int(pages) * cost
                print("That would be: " + str(+costT) + " colones.")
            if paper == 2:
                cost = 250
                costT = int(pages) * cost
                print ("That would be: " + str(+costT) + " colones.")

Any extra input on the code is also appreciated.
Thanks in advance.

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

>Solution :

color and paper and strings, you treat them as integers, the values will never match. Also when you type papel instead of paper.
Here’s how the code would look like after fixing these bugs:

chooseS = input('If you need the scanning service type 1, if you need printing press 2. ')
pages = (int(input('How many pages do you need?')))
costT = 0
cost = 0
costS = 0
color = 0

if chooseS == str(1):
    costS = 20
    email = input("Type the email where you want to receive the scanned document.")
    costT = costS*pages
    print("That would be " + str(costT) + " colones. You will receive it at the following adress: " + email + ".")
else:
    if chooseS == str(2):
        color = input("If you need it printed in color type 1. If you need black and white type 2. ")
        if color == str(1):
            paper = input("Regular paper: type 1. Film paper:  type 2. Sticker paper: type 3.")
            if paper == str(1):
                cost = 25
                costT = int(pages) * cost
                print("That would be: " + str(+costT) + " colones.")
            if paper == str(2):
                cost = 250
                costT = int(pages) * cost
                print("That would be: " + str(+costT) + " colones.")
            if paper == str(3):
                costo = 300
                costoT = int(pages) * cost
                print("That would be: " + str(+costT) + " colones.")
        if color == str(2):
            paper = input("Regular paper: type 1. Sticker paper: type 2. ")
            if paper == str(1):
                cost = 15
                cost = int(pages) * cost
                print("That would be: " + str(+costT) + " colones.")
            if paper == str(2):
                cost = 250
                costT = int(pages) * cost
                print ("That would be: " + str(+costT) + " colones.")

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