+ 1
I want to know how I can count multiple times s input in this code to work
6 Answers
+ 1
Use a while loop like
While True:
So that it can easily enter the loop and then ask for the input there......so it will keep asking input for stopping this you can also include a condition like if user input y it will again ask for input otherwise exit the loop and finish the program âïž
Ex:
while True:
y = input()
""".........
enter your
Logic........"""
abc = input()
if abc ="y":
continue
else:
break
Use this code:
total = 0
while True:
y = input()
if y in "Nachos":
total += 6.00
if y in "Pizza":
total += 6.00
if y in "Cheeseburger meal":
total += 10.00
if y in "Water":
total += 4.00
if y in "Coke":
total += 5.00
else:
print("Not in data")
tax = total*0.07
print(total+tax)
ab = input("Want tk use again(type y for yes or n for no)?")
if ab == "y":
continue
elif ab == "n":
break
else:
print("Invalid Input")
break
+ 2
Which language is it? Pls change the question tags to the language.
Also, pls save the code in Code Playground, as public, then edit the question, using "+" button to link the code. Makes it way easier for us to exchange and test ideas.
You can reverse the logic: loop through the words in input, then count occurrences of the specific ones.
Multiple word patterns, like "Cheeseburger meal", will require additional logic, but good coding also requires solving one problem at a time.
+ 2
Alejandro47
You will need to use a while loop to continue prompting input until an exit condition is met.
y = input()
while y != 'exit':
if pizz...
etc
etc
y = input()
The snippet shows that the while loop will test your input, then will prompt again for another input which it will test.
when y == "exit", the loop will terminate
+ 2
Avi , though your answer helps solving the problem, it defeats learning, which is the idea of SoloLearn.
Pls always prefer giving hints for the OP to find the solution, instead of giving finished code.
+ 2
Emerson Prado ok will take care next time......
+ 1
Emerson Prado
đ