zhiwehu / Python-programming-exercises

100+ Python challenging programming exercises
26.85k stars 6.83k forks source link

Q17 alternate answer ask for revision #177

Open choonhongyeoh0241 opened 2 years ago

choonhongyeoh0241 commented 2 years ago

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()

Aneousion commented 1 year ago

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