i'm making a program after the user finishes answering asks him to repeat or if he wants to enter another values and keep asking till the user says different than continue

Recommended Answers

All 3 Replies

Sounds like you need a loop. What have you tried so far? In pseudo -code it looks sort of like this (with the test at the top)

continue = yes

while continue = yes
    Get user input
    Do processing
    Prompt user to continue

I've always preferred test-at-the-bottom for this pattern - keeps it all more local ...

      Get user input
      Do processing
      Ask user "continue?"
while user says "yes"

I prefer test at the bottom for this as well but Python doesn't allows it unless you use a break like

while True:
    inp = input("user input: ")
    if input("do you want to continue (y/n): ") == "n": break

which, I admit, is cleaner than my pseudo-code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.