0 votes
1 view
in Python by (44.6k points)

I want to know if the user enters y it should print:

This will do the computation

But, I am getting a syntax error on IF answer=="y"

answer = str(input("Is the information correct? Enter Y for yes or N for no"))

proceed="y" or "Y" 

If answer==proceed:

print("this will do the calculation"):

else:

exit()

1 Answer

0 votes
by (96.7k points)

You can refer to the below approach:

if answer in ['y', 'Y', 'yes', 'Yes', 'YES']:

    print("this will do the calculation")

Another approach:

if answer.lower() in ['y', 'yes']:

    print("this will do the calculation")

For more information regarding the same, kindly refer to the python certification course. 

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
2 answers
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...