0

How To Get The Answer Without Any Error When The input() Function Is Used But The Input Is Not Give ?

If I Make A Program a = input() But The Input Is Not Give Then The Error Is Done . Then Please Tell Me That How To Run That Program Without Any Error And Input. Please !!!!!

30th Dec 2020, 3:11 PM
Tirthen Patel
Tirthen Patel - avatar
5 Answers
+ 7
Aerith , please show us your attempt first. At the moment we have to guess what your problem is. Thanks
30th Dec 2020, 3:39 PM
Lothar
Lothar - avatar
+ 5
User try and except Or use a = input() or "Krish" this will first ask for an input and if the input is left blank then the second text will be used.
30th Dec 2020, 3:14 PM
Krish
Krish - avatar
+ 3
x = input() if x == "": x = -99
30th Dec 2020, 3:18 PM
Lisa
Lisa - avatar
+ 3
Totally ahree with Krish. a = input() or "helloworld" takes "helloworld" as default value if no input given. Like a function default parameter: def func(a="helloworld"): ____return a 👍
30th Dec 2020, 5:54 PM
đŸ”„EACYđŸ”„
đŸ”„EACYđŸ”„ - avatar
+ 3
a="" while a="": a=input() this will ask again and again until an input is given if its blank then it will ask again and if you need specific answers then use this answers=['an','example','string','list'] a=input('') while a not in answers: print('invalid answer') a=input('enter something')
31st Dec 2020, 3:14 AM
Ireneo language