rage / programming-24

63 stars 39 forks source link

A code mistake in the exercise "Soup or no soup" part 1 conditional statements. Doesn't accept the right answers. #5

Closed PavelLange closed 8 months ago

PavelLange commented 10 months ago

I wrote a code (below) and I checked it many times through Visual Studio and it works perfectly well but when I press the button submit it shows an error that reads:

_FAIL: PythonEditorTest: test_1_kramer1 With input Kramer, 1 your program should print out Next please! your program printed out The total cost is 5.9

So I fixed as asked and it gives the same response that reads:

_FAIL: PythonEditorTest: test_1_kramer1 With input Kramer, 1 your program should print out The total cost is 5.9 your program printed out Next please!

I even tried to replace in my code the line number 5 with "else:" and the error is still the same. Is there anything wrong with the exercise or my code should look somehow different?

The code:

name = input("Please tell me your name: ") price = 5.90 if name == "Jerry": print("Next please!") if name != "Jerry": portions = int(input("How many portions of soup? ")) total = portions * price print(f"The total cost is {total}")

aygupt1822 commented 8 months ago

Probably the indentation in if block can be the issue... name = input("Please tell me your name: ") price = 5.90 if name == "Jerry":     print("Next please!") if name != "Jerry":     portions = int(input("How many portions of soup? ")) total = portions * price print(f"The total cost is {total}")

Gudkat commented 8 months ago

The exercise requires printing "Next please!" for all inputted names, for Kramer in this particular test case. The code above only prints "Next please!" for inputted name "Jerry".