How can I command the user to enter value of x so condition can be true | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can I command the user to enter value of x so condition can be true

x=int(input('enter values :')) if x<=10 : print ('''condition true''') else : print ('''invalid''')

18th Jul 2020, 6:09 AM
Ajay
Ajay - avatar
5 Answers
+ 12
Ajay you're looking for something like this?? https://code.sololearn.com/co91kyL5Cihs/?ref=app
18th Jul 2020, 6:17 AM
Simba
Simba - avatar
+ 2
No you might as well want to use a Boolean like in c++ : Int x ; Cin>>x; While (x!=true ){ Book x = true ;} correct me if I am wrong ☹️
19th Jul 2020, 6:23 PM
Pjc
Pjc - avatar
+ 1
Ajay You can't command the user to do anything. What you can do is use a try and except block in a while loop so that it will keep asking for input until the condition is met Something like this: https://code.sololearn.com/cEAKWLEmjV59/?ref=app
18th Jul 2020, 6:25 AM
Tomiwa Joseph
Tomiwa Joseph - avatar
0
But Ithink it is possible in python
18th Jul 2020, 6:30 AM
Ajay
Ajay - avatar
- 1
No
18th Jul 2020, 6:19 AM
Ajay
Ajay - avatar