Skip to content

Q17 alternate answer ask for revision #177

@choonhongyeoh0241

Description

@choonhongyeoh0241

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

Activity

Aneousion

Aneousion commented on Jan 1, 2023

@Aneousion

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @choonhongyeoh0241@Aneousion

        Issue actions

          Q17 alternate answer ask for revision · Issue #177 · zhiwehu/Python-programming-exercises