79221808

Date: 2024-11-25 06:11:51
Score: 1.5
Natty:
Report link

My first thought: If it is only low and high, you could rather use boolean arrays. Those would also help in comparing, manipulation...

X = np.array([False]*10)
X[2]=True
print(['high' if x else 'low' for x in X])

This snippet results in

['low', 'low', 'high', 'low', 'low', 'low', 'low', 'low', 'low', 'low']

which is very close to your desired output. Doesn't that also solve your problem? Even if you have more than two strings that might occur, I would think of encoding them in an integer rather than always adapting to the longest string. This also makes it easier to maintain the code, exchange or translate a string later, etc.

Reasons:
  • RegEx Blacklisted phrase (1.5): solve your problem?
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (0.5):
Posted by: André