Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (18.4k points)

How do I get this program repeat when 'again' gets 'Y' or 'y'? Yesterday the same code worked smh, but today it closes the program whatever I write in there) And yeah...tabulation is wrong but it's because StackOverflow copied it in some weird way :))

   while True:   

start = input("What do you want to do? + - * /  ")

if start == '+':

    x = float(input("digit 1  "))   

    y = float(input("digit 2  "))

    res = x + y

    print('The result is ' + str(res))

    again = input('Do u want to try again? Y/N ')

    if again == 'N' or 'n':

        break

1 Answer

0 votes
by (36.8k points)

Look, you are using the wrong syntax for checking the condition. 

Use this syntax :

if again=='N' or again=='n':

    break

Learn Data Science with Python to improve your technical knowledge.

Browse Categories

...