Python-programming-exercises icon indicating copy to clipboard operation
Python-programming-exercises copied to clipboard

Q17 alternate answer ask for revision

Open choonhongyeoh0241 opened this issue 3 years ago • 1 comments

def inputValue(): count = 0

while True:
    x = input("Enter value [D val/ W val/ total]: ")

    x = x.split(" ")

    if x[0] == 'total':
        print(count)
    elif x[0] == 'D':
        count += int(x[1])
    elif x[0] == 'W':
        count -= int(x[1])
    else:
        print("Wrong input!")
        continue

inputValue()

  • To realize if programmer wishes to print the total or not without debugging every time but straight to run the program

choonhongyeoh0241 avatar Aug 10 '22 07:08 choonhongyeoh0241

This is fine. You can choose to print the total.

Aneousion avatar Jan 01 '23 20:01 Aneousion