0
import cs50

while True:

    print ("O! Hail!, How Much Change Is Owed?")

    n = cs50.get_float()

    if n >= 0:

        break

    q = 25
    q1 = 0
    d = 10
    d1= 0
    ni = 5
    ni1 = 0
    p = 1

    nocq = 0

    nocd = 0

    nocni = 0

    nocp = 0

    change = 0

    count = 0

    change = round (n * 100)

    if change >= q:

        q1 = change % q

        nocq = round ((change - q1) / q)

        count = nocq

        if q1 >= d:

            d1 = change % d

            nocd = round ((q1 - d1) / d)


        elif change < q and change >= d:

                d1 = change % d

                nocd = round ((change - d1) / d)


        if d1 >= ni:

            ni1 = change % ni

            nocni = round((d1 - ni1) / ni)


    elif change < d and change >= ni:

            ni1 = change % ni

            nocni = round ((change - ni1) / ni)


    if q1 < d and q1 < ni:

            q1 = p

            if d1 < ni1:

                d1 = p

    elif change < q and change < d and change < ni:

        change = p

        count = nocq + nocd + nocni + p

    print (count)

    print ()
6
  • 3
  • The answer from @curiouskiwi to your other question was absolutely correct. If a number greater-equal 0 is entered, it breaks out of the while loop and the program ends. It doesn't even print the input, that's just on the screen from when it was typed in. Maybe it is an indent problem: all of the code after the break is part of the while loop. If you want it to execute after the break, it needs to be "outdented". Mar 30 '17 at 13:16
  • @DinoCoderSaurus, please, what's outdented and how do I achieve (do) it and is it advised. Or what other condition can I use to keep it within the loop? Please, help! Thanks in anticipation. Mar 30 '17 at 13:44
  • The lines after break should not be indented. They should be on the same "level" as the while. Mar 30 '17 at 13:55
  • @DinoCoderSaurus, thanks, dear. SuperNovaCoder, just gave me the hint a while ago and I implemented it. It's printing now. Thanks, again. Mar 30 '17 at 14:08
0

The problem was that of indentation. I did not indent my code properly according to python indentation rules and, as such, the program breaks out of the loop and does not execute other codes that can generate the result. As soon as that, and order logical errors were taken care of, the program worked as per expected! Thanks to Dino, Curiuoskiwi and SuperNovaCoder!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .