In python3 cant we use if statement as - x= int(input (' 2+2') if x = 4 print ('correct') and if we can then how? | SoloLearn: Learn to code for FREE!

0

In python3 cant we use if statement as - x= int(input (' 2+2') if x = 4 print ('correct') and if we can then how?

12/11/2017 3:41:39 PM

Arjun Mahanty

3 Answers

New Answer

+3

x = input("2+2") if x == "4": print("correct") else: print("incorrect") or if you want the if statment to have a int you can use x = int(input("2+2")) if x == 4: print("correct") else: print("incorrect")

+1

if int(input('2+2') )==4: print("correct") else: print('no')

+1

https://code.sololearn.com/cRnKCjzk876D/?ref=app Your code appears to be working. If someone helped you, note you can upvote or mark them as best answer. If you mean you aren't seeing the prompt, that's just how SoloLearn works (in batch mode, input is gathered before prompts are shown).