I try my best to explain what I need:
If len(x) > 5:
sample = func_sample(5)
If sample meet conditionA:
Then use sample
Else go to elif bellow
Elif len(x) > 4:
sample = func_sample(4)
if sample meet conditionA:
Then use sample
Else go the else bellow
Else:
sample = func_sample(3)
I know in VBA there is option goto but not in Python, so I am a bit struggling here
>Solution :
Something like this? (assuming you actually also use the sample in the last case…)
def get_sample(L):
if L > 5:
sample = func_sample(5)
if conditionA(sample):
return sample
if L > 4:
sample = func_sample(4)
if conditionA(sample):
return sample
return func_sample(3)
sample = get_sample(len(x))
use_sample(sample)