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!
New course! Every coder should learn Generative AI!
Try a free lesson
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?

11th Dec 2017, 3:41 PM
Arjun Mahanty
Arjun Mahanty - avatar
3 Answers
+ 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")
11th Dec 2017, 3:50 PM
Mooaholic
Mooaholic - avatar
+ 1
if int(input('2+2') )==4: print("correct") else: print('no')
11th Dec 2017, 3:51 PM
Oma Falk
Oma Falk - avatar
+ 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).
11th Dec 2017, 5:19 PM
Kirk Schafer
Kirk Schafer - avatar