0

DEFAULT PARAMETERS AND USER INPUTS IN PYTHON

Given function with a default parameter like def f(input1, input2 = 'default') calling it with direct inputs (for example f('a' , 'b'), f('a')) works, while requesting the inputs from a user like f(input() , input()) ; f(input(),) ; f(input()) doesn't works, raising a missing input or EOF error, does It exist a method to handle user inputs while admitting a default parameter?

5th May 2020, 12:49 PM
Bobo
1 ответ
+ 1
You can do a try-except block. try: a = input() except: a = 'default' More on the syntax here: https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2441/?ref=app
5th May 2020, 1:57 PM
Kishalaya Saha
Kishalaya Saha - avatar