I'm trying to randomly break and pass loop but random.choice([pass,break]) just won't work and shows invalid syntax.
Any Suggestions..?
I'm trying to randomly break and pass loop but random.choice([pass,break]) just won't work and shows invalid syntax.
Any Suggestions..?
When you use pass and break as arguments in random.choice, python thinks they are variable names. But they're not.
res = random.choice(['pass','break'])
if res == 'pass':
pass
if res == 'break':
break