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 !!!!!
5 Answers
+ 7
Aerith , please show us your attempt first. At the moment we have to guess what your problem is. Thanks
+ 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.
+ 3
x = input()
if x == "":
x = -99
+ 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
đ
+ 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')