Hello I'm newbie in python and I wanted to know if I can create a function that only accepts certain types of values, in this case string, else error
parameter that needs to be string
|
v
def isfloat(a):
if a.count('.') > 1:
return False
for c in a:
if c.isnumeric() or c == '.':
v = True
else:
return False
return v
aisstr,you can useisinstance(a,str).if not isinstance(argument, str): raise ValueError('argument has to be a string')